github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/contrib/vagrant-docker/README.md (about) 1 # Vagrant integration 2 3 Currently there are at least 4 different projects that we are aware of that deals 4 with integration with [Vagrant](http://vagrantup.com/) at different levels. One 5 approach is to use Docker as a [provisioner](http://docs.vagrantup.com/v2/provisioning/index.html) 6 which means you can create containers and pull base images on VMs using Docker's 7 CLI and the other is to use Docker as a [provider](http://docs.vagrantup.com/v2/providers/index.html), 8 meaning 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 23 The 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 ``` 26 description "Docker daemon" 27 28 start on filesystem 29 stop on runlevel [!2345] 30 31 respawn 32 33 script 34 /usr/bin/dockerd -H=tcp://0.0.0.0:2375 35 end script 36 ``` 37 38 Once 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 ``` 41 ssh -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 46 Note that because the port has been changed, to run docker commands from within the command line you must run them like this: 47 48 ``` 49 sudo docker -H 0.0.0.0:2375 < commands for docker > 50 ```