This shows how to use the exact same .kitchen.yml
for both Vagrant/VirtualBox and Vagrant/Docker when using the kitchen-vagrant driver.
Why not simply using plain Docker with the kitchen-docker driver?
Well, there is a subtle difference: while plain kitchen-docker is more lightweight and starts up faster, kitchen-vagrant can cache downloaded files via vagrant-cachier, which can save you lots of traffic and idle time during the kitchenci run.
This is pretty straightforward. VirtualBox is already the default provider, so you just run kitchenci:
$ kitchen test
This requires some trickery to make it work transparently without changing the .kitchen.yml
:
- you need to provide a docker basebox that works via
config.vm.box
in the Vagrantfile - you need to add this basebox under the "opscode-ubuntu-14.04" name / for the docker provider
So let's do the trickery first:
$ vagrant box add opscode-ubuntu-14.04 https://atlas.hashicorp.com/tknerr/boxes/baseimage-ubuntu-14.04/versions/1.0.0/providers/docker.box --provider=docker
Then we can simply set the VAGRANT_DEFAULT_PROVIDER
to docker and run kitchenci:
$ set VAGRANT_DEFAULT_PROVIDER=docker
$ kitchen test
For the sake of completeness, lets show the plain kitchen-docker variant too. This uses a separate .kitchen.docker.yml
file to override the vagrant driver with the docker driver (including some optimizations to cache the omnibus installer and verifier gems in a docker layer).
So you have to set the KITCHEN_LOCAL_YAML
accordingly before running kitchenci:
$ set KITCHEN_LOCAL_YAML=.kitchen.docker.yml
$ kitchen test