Forked from https://gist.github.com/yikaus/c39ec878ae4735db867f
Example setup on Mac
People can use boot2docker or docker machine to provison a docker vm , I would like use vagrant myself to better understand the architecture.
install vagrant & vbox (5.0.3) https://www.virtualbox.org/download/testcase/VirtualBox-5.0.3-102165-OSX.dmg
Use attached Vagrantfile to provision jessie64 If some errors on ip change it to any different network class
Put it into your vm dir , eg. ~/dev/vm/jessie and then
cd ~/dev/vm/jessie && vagrant up
~vm$ sudo echo 'deb http://http.debian.net/debian-backports squeeze-backports(-sloppy) main' > /etc/apt/sources.list.d/backports.list
~vm$ sudo apt-get update && sudo apt-get install docker.io && sudo gpasswd -a vagrant docker && sudo service docker restart
create dockervm.command as attached and drag it into OSX dock
docker build -t tutum/centos:centos7 centos7
vi wheezy/Dockerfile
add line "apt-get install -y python" and save
docker build -t tutum/debian:jessie jessie/
ssh-keygen -t rsa -b 4096 -C "ansible@local"
Specify the file name as /home/vagrant/.ssh/docker.pem
docker run --name devcentos7 -d -p 2222:22 -e AUTHORIZED_KEYS="
cat /home/vagrant/.ssh/docker.pem.pub
" tutum/centos:centos7 docker ps -a docker inspect --format '{{ .NetworkSettings.IPAddress }}' [CONTAINER-ID] 172.17.0.11
docker run --name devdebian8 -d -p 2224:22 -e AUTHORIZED_KEYS="
cat /home/vagrant/.ssh/docker.pem.pub
" tutum/debian:jessie docker ps -a docker inspect --format '{{ .NetworkSettings.IPAddress }}' [CONTAINER-ID] 172.17.0.12
Install ansible on vagrant
sudo apt-get install -y ansible
Change the settings from ansible.cfg and inventory file as attached in /etc/ansible/ansible.cfg
Change the /etc/ansible/hosts file as in the inventory file
mkdir ~/dev/work
Test setting with
ansible -m ping all
(If some errors, install python on the guest container)
Use the attached test.yaml to verify docker instance configuration Paste the inventory file here too
vim inventory ansible-playbook -i inventory test.yml --user root
Wait for the results