Docker: How to ssh into a docker machine with IP ?

In this post, we will look how to do ssh into a docker machine directly and to use it as a VM machine.

Ideally we do ssh into a docker machine using “docker-machine ssh” command like below.

$ docker-machine ls
NAME           ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER     ERRORS
firstmanager   -        virtualbox   Running   tcp://192.168.99.100:2376           v18.09.1   
worker1        -        virtualbox   Running   tcp://192.168.99.102:2376           v18.09.1   
worker2        -        virtualbox   Running   tcp://192.168.99.101:2376           v18.09.1   
$ docker-machine ssh firstmanager
   ( '>')
  /) TC (\   Core is distributed with ABSOLUTELY NO WARRANTY.
 (/-_--_-\)           www.tinycorelinux.net

docker@firstmanager:~$ 

SSH into Docker Machine VM
1. First view IP address using “docker-machine ls” command.

$ docker-machine ls
NAME           ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER     ERRORS
firstmanager   -        virtualbox   Running   tcp://192.168.99.100:2376           v18.09.1   
worker1        -        virtualbox   Running   tcp://192.168.99.102:2376           v18.09.1   
worker2        -        virtualbox   Running   tcp://192.168.99.101:2376           v18.09.1  

2. Now ssh the IP address with docker user.
You can become root using “sudo -i” command.

$ ssh 192.168.99.100 -l docker
The authenticity of host '192.168.99.100 (192.168.99.100)' can't be established.
ECDSA key fingerprint is SHA256:Yqu59Rd9O9lf8IhwWMvbJWbOyX/hmd5CKGNB+lCucOA.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.99.100' (ECDSA) to the list of known hosts.
docker@192.168.99.100's password: 
   ( '>')
  /) TC (\   Core is distributed with ABSOLUTELY NO WARRANTY.
 (/-_--_-\)           www.tinycorelinux.net


docker@firstmanager:~$ sudo -i
root@firstmanager:~# 

Default Password for Docker user is : tcuser

Leave a Reply

Your email address will not be published.