docker-machine version 0.2.0 docker version 1.6.2
I\'m using docker-machine to create a machine using VirtualBox. Everything works fine but I\'d like to ssh into th
If for some reason you'd rather use the ssh
command rather than docker-machine ssh
, you can do
ssh `docker-machine ip machine_name` -ldocker -i ~/.docker/machine/machines/machine_name/id_rsa
For mac OX,the machine and its keys are located here (make sure you have the keys in there, something like the below:
~/project/dev/docker_notes za$ ls /Users/za/.docker/machine/machines/default/
.DS_Store ca.pem config.json disk.vmdk id_rsa.pub server-key.pem
boot2docker.iso cert.pem default/ id_rsa key.pem server.pem
1) list available vms.
> ~/project/dev/docker_notes za$ docker-machine ls
> NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
> default - virtualbox Running tcp://192.168.99.100:2376 v1.11.0
In my case, the name of the machine is default. So, just
~/project/dev/docker_notes za$ docker-machine ssh default
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 1.11.0, build HEAD : 32ee7e9 - Wed Apr 13 20:06:49 UTC 2016
Docker version 1.11.0, build 4dc5990
docker@default:~$ vi
.ash_history .ashrc .docker/ .local/ .profile .ssh/ log.log
docker@default:~$ ls
log.log
As you can see, I am able to ssh into docker-machine/instance.
docker@default:~$ uname -a
Linux default 4.1.19-boot2docker #1 SMP Thu Apr 7 02:41:05 UTC 2016 x86_64 GNU/Linux
You can also follow this > howto - docker
Finally, I found an answer :
I'm on Windows with Docker Toolbox (Docker Machine).
If I docker-machine -D ssh default
, I find that the SSH parameters should be :
Host : localhost
Port : 51701
User : docker
Key : .docker\machine\machines\default\id_rsa
When I change my Putty/MobaXterm settings to match, voila, I can SSH into the container.
You can log into docker-machine hosts by just running
docker-machine ssh default
(Using the "default" host here)
The identity files should be stored under ~/.docker/machine/machines
. If you want to log into a container (as opposed to the host), use docker exec
as suggested by user2915097.
We can also ssh into the docker via following command -
docker exec -it /bin/sh
if you really need to do it via ssh
, this is working with docker 1.8.2
init docker:
eval "$(docker-machine env default)"
get the IP from your default docker machine:
docker-machine ip default
this prints something like this out: 192.168.99.100
ssh docker@192.168.99.100
password is tcuser
but you can also use the identity file, see other answer