Test Kitchen, Docker and CentOS 7

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: []

Michael is a polyglot software engineer, committed to reducing complexity in systems and making them more predictable. Working with a variety of languages and tools, he shares his technical expertise to audiences all around the world at user groups and conferences. You can follow @mheap on Twitter

Thoughts on this post

Leave a comment?

Leave a Reply