docker ps shows empty list

I built a docker image from a docker file. Build said it succeeded. But when I try to show docker containers through docker ps (also tried docker ps -a), it shows an empty list. What is weird is that I'm still able to somehow push my docker image to dockerhub by calling docker push "container name".

I wonder what's going on? I'm on Windows 7, and just installed the newest version of dockertoolbox.

116157 次浏览

docker ps shows (running) containers. docker images shows images.

A successfully build docker image should appear in the list which docker images generates. But only a running container (which is an instance of an image) will appear in the list from docker ps (use docker ps -a to also see stopped containers). To start a container from your image, use docker run.

For me, docker ps -a and docker images both returned an empty list even tho I had many docker containers running. I tried rebooting system with no luck. A quick sudo systemctl restart docker fixed this "bug".

You can run the command without the -d option. So you have the output displayed.

It may be that the application failed to start.

For me, the only thing resolving the issue is to reinstall docker. Also, one must be sure that the disk is not full.

This is the command that I use, but it may vary depending on the version of docker already installed:

apt-get install --reinstall docker.io

If prompted, choose "yes" to automatically restart docker daemon

for Linux,

at first, see all the running container

sudo docker ps

try restarting

sudo systemctl restart docker

remove previous docker image with the same name if there is any

sudo docker rm docker_container_id

once again run

sudo docker run -d --name container_name image_name

This should work

or uninstall docker and install it again

try restarting

sudo systemctl restart docker.socket
sudo systemctl restart docker

In the Dockerfile instructions, make sure the CMD commands are in between double-quotes not single-qoute

for example:

CMD [ "node" , 'index.js'] Here there is a mistake !!

Correct one is :

CMD [ "node" , "index.js"]

This mistake will make the container run and exit immediately.