Test Kitchen, Docker and CentOS 7

This article was published 3 years ago. Due to the rapidly evolving world of technology, some concepts may no longer be applicable.

Whilst trying to add some tests to some Chef cookbooks that run on CentOS 7, I ran into an issue where systemd wouldn’t start in a docker container (and so my services wouldn’t start up). It was failing with the following error: Failed to get D-Bus connection: Operation not permitted

The solution was to make the container privileged and to set run_command to /usr/sbin/init. systemd still shows that performance is degraded, but at least it starts my services now. Here’s a complete .kitchen.yml that solves the issue for me:

---
driver:
  name: docker
  use_sudo: false
  privileged: true
  run_command: /usr/sbin/init

provisioner:
  name: chef_zero

platforms:
  - name: centos
    image: centos:7

suites:
  - name: default
    run_list: []

Thoughts on this post

Thanks this was really helpful.

Leave a comment?