Test Kitchen, Docker and CentOS 7

16 Dec 2016 in Tech

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:

name: docker
use_sudo: false
privileged: true
run_command: /usr/sbin/init
name: chef_zero
- name: centos
image: centos:7
- name: default
run_list: []