Solved Error : docker-machine ls command asking for password.

You can face an interesting issue when docker-machine command repeatedly asks for password.

1. Issue
docker-machine ls command asks for password.

$ docker-machine ls
Password:

2. Root Cause of the issue
Above issue is caused when any of your docker machine is not deployed correctly and the command is not able to get that machine details.
And hence it prompts for the password.

To resolve the issue, you need to identify which docker machine you built last.

You can still see the output of other docker machines which don’t have any issue.

$ docker-machine ls
Password:

$ docker-machine ls --filter name=manager
NAME           ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER     ERRORS
firstmanager   *        virtualbox   Running   tcp://192.168.99.100:2376           v18.09.0   

$ docker-machine ls --filter name=worker
Password:

3. Issue Confirmation
If you inspect the VM with issue, we can see no IP address is assigned:

$ docker-machine inspect worker1
{
    "ConfigVersion": 3,
    "Driver": {
        "IPAddress": "",
        "MachineName": "worker1",
        "SSHUser": "docker",
        "SSHPort": 0,
        "SSHKeyPath": "",
------ Output Truncated ------------

If you try to get IP address, then also it will show error message.

$ docker-machine ip worker1
Password:

4. Resolution of the Issue
a. First identify if the issue is with a particular machine.
Stop the suspected VM and try to run the command “docker-machine ls”

If it runs fine, then this is the corrupt machine.

$ docker-machine stop worker1
Stopping "worker1"...
Machine "worker1" was stopped.

$ docker-machine ls
NAME           ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER     ERRORS
firstmanager   *        virtualbox   Running   tcp://192.168.99.100:2376           v18.09.0   
worker1        -        virtualbox   Stopped                                       Unknown    

b. Start the machine again to resolve the issue with network.

$ docker-machine start worker1
Starting "worker1"...
(worker1) Check network to re-create if needed...
(worker1) Waiting for an IP...

Leave a Reply

Your email address will not be published.