We started using Chef a while ago and one of the first steps we took was to use Docker instead of Vagrant for performing tests due to it’s faster setup.
After all this time I can say it was a nice experience and now our CI is happily testing our in minutes. So…
What do you need?
After that you just need to setup your
kitchen.yml to use dokken as driver like so:
--- driver: name: dokken chef_version: latest transport: name: dokken provisioner: name: dokken ...
transport and the
provisioner are set to dokken so kitchen will use the lighter tooling from the driver. Then you can setup your platform to test your cookbooks:
- name: ubuntu-16.04 driver: image: ubuntu:16.04 pid_one_command: /bin/systemd intermediate_instructions: - RUN /usr/bin/apt-get update
Docker is designed for isolating and packaging processes that runs as the only process inside a container.
If your cookbook setup services you may need to choose a complete Docker base image that normally is bigger in size, also you need to explicitly start the system daemon (such as
systemd) like you saw on the code snippet earlyer.
Do not try to run Docker inside a container. If your cookbook uses Docker somehow is better to use Vagrant instead because then you may need to manually setup the container to host docker and that is a pain.