Docker-machine Virtualbox container not showing in docker ps

dockervirtualbox

On an up-to-date Ubuntu 15.04 machine with Docker version 1.8.2, build 0a8c2e3.

If I run the standard docker-machine test as instructed here:

$ docker-machine create --driver virtualbox dev
Creating VirtualBox VM...
Creating SSH key...
Starting VirtualBox VM...
Starting VM...
To see how to connect Docker to this machine, run: docker-machine env dev
$ docker-machine ls
NAME        ACTIVE   DRIVER       STATE     URL                         SWARM
dev                  virtualbox   Running   tcp://192.168.99.101:2376

So it's running, and I can see it in Virtualbox with the correct user and network interfaces.

So I do the next step to "to tell Docker to talk to that machine".

$ eval "$(docker-machine env dev)"

But when I attempt to do a "docker ps", the container does not show:

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Why does docker ps not show my docker-machine container?

Best Answer

Well that's because you haven't actually started a container yet. You have just created a VM on which the docker server can run.

Running the following just says that the docker command should use the vm you just created. The docker command does not point to a container, but a machine (which is named "dev" in this case).

eval "$(docker-machine env dev)"

You will see the VM you just created by opening up virtualbox.

Now if you want to actually start a container you can try a command like the following:

docker run --name=test_container --rm -it alpine /bin/bash

Open up a new terminal window (while that container is still running) and init your environment again:

eval "$(docker-machine env dev)"

Now if you run docker ps you will see the container that you have running.