Show Docker Containers Stopped

I am new to Docker and I would like to list stopped containers.

With docker ps :

 sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 

Nothing appears because I restarted the machine and did not configure them to automatically start containers.

So when I try to start the container, it says:

 sudo docker run -d -p 8080:80 --name=angular_moviemasher moviemasher/angular-moviemasher docker: Error response from daemon: Conflict. The name "/angular_moviemasher" is already in use by container b4428b708711c15233f558e70f58cb7800e23c4a6a57534abfa5818912630a37. You have to remove (or rename) that container to be able to reuse that name.. See 'docker run --help'. 

Therefore, I would like to see which Docker containers are already installed and run them.

In the Docker Cheat Sheet documentation with examples, I can only find an example of how to show working containers:

Container Information

Show working containers. With the -a option, it shows started and stopped containers.

docker PS

+11
source share
4 answers

As you said, docker ps -a will show stopped and running containers (all containers). The following command will show you stopped containers.

 docker ps -a | grep Exit 

Now you can run docker logs container-id in your container to see what is going wrong.

+20
source

Well you gave yourself the answer:

Container Information

To show running containers. If the option is -a , it shows stopped containers.

docker ps

So try

 sudo docker ps -a 
+4
source

If docker ps -a doesn’t show anything after restarting the machine, try restarting the Docker daemon (sometimes this happens to me even after shutting down).

+2
source

Another option not mentioned in the answers above:

 docker container list --all 

It was added in Docker 1.13 (January 2017) and seems to be the recommended syntax :

In Docker 1.13, we regrouped each command so that it was under the logical object with which it interacts. For example, list and launch of containers are now subcommands of the Docker container, and history is a subcommand of the Docker image.

docker container list
docker container start
docker image history

These changes will allow us to clear the syntax of the Docker command-line interface, improve the help text, and simplify the use of Docker. The old command syntax is still supported, but we encourage everyone to accept the new syntax .

0
source

All Articles