• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..06-Dec-2017-

README.mdH A D06-Dec-20172 KiB5133

README.md

1# Vagrant integration
2
3Currently there are at least 4 different projects that we are aware of that deals
4with integration with [Vagrant](http://vagrantup.com/) at different levels. One
5approach is to use Docker as a [provisioner](http://docs.vagrantup.com/v2/provisioning/index.html)
6which means you can create containers and pull base images on VMs using Docker's
7CLI and the other is to use Docker as a [provider](http://docs.vagrantup.com/v2/providers/index.html),
8meaning you can use Vagrant to control Docker containers.
9
10
11### Provisioners
12
13* [Vocker](https://github.com/fgrehm/vocker)
14* [Ventriloquist](https://github.com/fgrehm/ventriloquist)
15
16### Providers
17
18* [docker-provider](https://github.com/fgrehm/docker-provider)
19* [vagrant-shell](https://github.com/destructuring/vagrant-shell)
20
21## Setting up Vagrant-docker with the Engine API
22
23The initial Docker upstart script will not work because it runs on `127.0.0.1`, which is not accessible to the host machine. Instead, we need to change the script to connect to `0.0.0.0`. To do this, modify `/etc/init/docker.conf` to look like this:
24
25```
26description     "Docker daemon"
27
28start on filesystem
29stop on runlevel [!2345]
30
31respawn
32
33script
34    /usr/bin/dockerd -H=tcp://0.0.0.0:2375
35end script
36```
37
38Once that's done, you need to set up an SSH tunnel between your host machine and the vagrant machine that's running Docker. This can be done by running the following command in a host terminal:
39
40```
41ssh -L 2375:localhost:2375 -p 2222 vagrant@localhost
42```
43
44(The first 2375 is what your host can connect to, the second 2375 is what port Docker is running on in the vagrant machine, and the 2222 is the port Vagrant is providing for SSH. If VirtualBox is the VM you're using, you can see what value "2222" should be by going to: Network > Adapter 1 > Advanced > Port Forwarding in the VirtualBox GUI.)
45
46Note that because the port has been changed, to run docker commands from within the command line you must run them like this:
47
48```
49sudo docker -H 0.0.0.0:2375 < commands for docker >
50```
51