Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Explain how to be able to connect to the Docker API when using Vagrant? #2280
Sorry if this issue could be best addressed by using StackOverflow, but for the past few days I've been having trouble trying to set up Docker such that I can connect to the remote API from my host machine.
I imagine this is pretty trivial to set up, but I can't find where this is documented and I think it should be mentioned in the installation docs for using Docker with Vagrant since it's probably a common use-case.
If someone can explain how it's supposed to be done, I'll be more than happy to document this myself.
First, you have to edit Docker config file /etc/init/docker.conf (in Vagrant VM) like this:
Note the "-H=...", your Docker API will be available on port 4243.
Restart Docker :
stop docker start docker
My Vagrant VM starts with SSH port (22) forwarded to host 3222 port:
To be able to reach Docker API from host machine, create SSH tunnel :
(Enter your vagrant user password -- "vagrant" by default.)
-- this will list Docker containers.
Hi @pyotr777 , thanks for helping me out!
When I start my vagrant VM I don't see any messages about port forwarding:
So I assume that this means that SSH is on port 22? In any case, when I try to run the command:
(I'm entering "vagrant" as the password, and this problem happens whether or not I run this command as sudo.)
I think this is just because I have the wrong password for root? When I try to run
Edit: never mind, I figured out how to change
Is this what's supposed to happen? It does seem that I can connect to both 1024 and 4243 from within this newly-created ssh terminal:
And when I try to connect from within the terminal I get after calling
But when I try to connect from my host plain old terminal:
What am I doing wrong?
I suppose by default vagrant forwards 22 port to 2222. In this case you have to run from you host machine this:
If your connect is successful, you'll have to open a new terminal window on your host machine to run more commands.
I forgot to mention, that after setting Docker Remote API on 4243 port, you will no longer be able to run commands like this:
Instead you'll have to connect to Docker on port 4243 like this:
Strictly speaking, Vagrant VM is not part of the Docker, and neither is SSH tunneling.
Not in the docs, but a PR to a doc in contrib/vagrant/ would be useful.
On Wed, Oct 23, 2013 at 8:46 AM, Peter email@example.com wrote: