Docker provision

Here is sample of docker provision:


Vagrant.configure("2") do |config| = "wildetech/hyper-u1404"
    config.vm.hostname = "docker.vm"

    # vagrant plugin install vagrant-hostmanager
    config.hostmanager.enabled = true
    config.hostmanager.manage_host = true

    config.vm.provision :shell, path: ""

#!/usr/bin/env bash

# Install latest docker
curl -sSL | sudo sh

# You can use docker without TLS like this:
# echo 'DOCKER_OPTS="-H=unix:///var/run/docker.sock -H="' | sudo tee --append /etc/default/docker

# And here is "secure" way
sudo apt-get install -y git ruby-dev
git clone certgen
sudo gem install certificate_authority
ruby certgen/certgen.rb docker.vm # You MUST generate keys for FQDN not for IP
sudo cp /root/.docker/*.pem /vagrant/
echo 'DOCKER_OPTS="--tlsverify -H=unix:///var/run/docker.sock -H= --tlscacert=/root/.docker/docker.vm/ca.pem --tlscert=/root/.docker/docker.vm/cert.pem --tlskey=/root/.docker/docker.vm/key.pem"' | sudo tee --append /etc/default/docker

# Lastly allow vagrant user to do things without sudo and restart docker
sudo gpasswd -a vagrant docker
sudo service docker restart

Docker client for windows can be found here:

Setting environment variables for docker client:

SET DOCKER_HOST=tcp://docker.vm:2376
SET DOCKER_CERT_PATH=C:\Users\Alexandr\Desktop\Docker

without them you should run commands like this:

docker.exe -H tcp:// ps

if you are running without TLS, or:

docker.exe --tlsverify --tlscacert=ca.pem --tlscert=cert.pem --tlskey=key.pem -H tcp://docker.vm:2376 ps

Important note: you MUST generate keys for FQDN rather than IP, otherwise you will get "x509: cannot validate certificate for because it doesn't contain any ip sans"

Unfortunatelly at current moment docker.exe having troubles with color codes. - here is manual where i have found ruby script