turkenh.provision_docker
provision_docker
A tool in Ansible to set up and start Docker containers for each server listed in your inventory. It's great for testing.
Read this blog post for guidance on how to use provision_docker
for testing.
Recommended Docker Images:
chrismeyers/centos6
chrismeyers/centos7
chrismeyers/ubuntu12.04
ubuntu-upstart:14.04
Note: The Dockerfiles for these images (link) are made to run system processes and OpenSSH.
Example Playbook
Testing with Travis-CI
Check out the .travis.yml file to learn how to test your role using Travis CI.
Mac OS X + docker-machine + VirtualBox
provision_docker
needs to SSH into containers. This means the container's IP should be reachable. If you're using Docker Toolbox on OS X, your VirtualBox containers might not connect to the host. Use the following commands to add a route to access the containers in the guest VM:
/usr/sbin/scutil -w State:/Network/Interface/vboxnet0/IPv4 -t 0
sudo /sbin/route -n add -net 172.17.0.0 -netmask 255.255.0.0 -gateway $(docker-machine ip)
Remember, this route won’t stay after a reboot. To keep the changes, edit /Library/LaunchDaemons/com.docker.route.plist
with the following content:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC '-//Apple//DTD PLIST 1.0//EN' 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'>
<plist version='1.0'>
<dict>
<key>Label</key>
<string>com.docker.route</string>
<key>ProgramArguments</key>
<array>
<string>bash</string>
<string>-c</string>
<!-- Change vboxnet0 to the correct interface for your setup, check it with ifconfig -->
<string>/usr/sbin/scutil -w State:/Network/Interface/vboxnet0/IPv4 -t 0;sudo /sbin/route -n add -net 172.17.0.0 -netmask 255.255.0.0 -gateway 192.168.99.100</string>
</array>
<key>KeepAlive</key>
<false/>
<key>RunAtLoad</key>
<true/>
<key>LaunchOnlyOnce</key>
<true/>
</dict>
</plist>
Mac OS X + docker-machine + VMware Fusion
Use this command to add the route:
sudo /sbin/route -n add -net 172.17.0.0 -netmask 255.255.0.0 -gateway $(docker-machine ip default)
Similar Tools
Provision docker containers using inventory.
ansible-galaxy install turkenh.provision_docker