I'm on OSX and I'd like to be able to SSH into the host vm in order to:
- Get access to a native docker environment. This facilitates understanding and debugging port forwarding issues.
- Vagrant rsync seems to leave a lot of unused synced directories that's eating up disk space that I'd like to recover.
To be clear, this question is NOT about ssh:ing into the docker containers that the Vagrant provider creates, but into the intermediate boot2docker host vm that Vagrant creates.
I know that a workaround is to not use the default boot2docker as the host vm (as explained in the answer here), but that's not what this question is about.
Oct 2015: Boot2docker is deprecated in favor of docker-machine. To login:
For vagrant host machines with vagrant password:
Otherwise with tcuser password:
Here is more information on why this works.
You can use SSH directly:
(password: tcuser, see https://github.com/boot2docker/boot2docker#ssh-into-vm)
And you can also copy/paste your public key to the boot2docker machine, so you don't need to type the password every time:
You can also forgo using
boot2docker
'sssh
function and do it "manually" like so:The arguments to
-p
is typically port 2022 but above shows how you can programmatically determine this if you want.Vagrant's boot2docker keeps boot2docker's ssh username and password.
https://github.com/boot2docker/boot2docker#ssh-into-vm
The port is forwarded from the local port
2022
by default. You can verify this:And then login:
You can ssh into docker host with
vagrant ssh docker-host-id
but first you need to know the docker-host-id.You can get a list of all active Vagrant environments with
vagrant global-status
command.To get the docker-host id you can filter with grep:
vagrant global-status | grep docker-host
you'll obtain an output similar to:
copy the first column id, and then ssh into docker-host:
vagrant ssh 68f58d0
vagrant global status docs