Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker: Show stopped Docker containers

Tags:

docker

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

With docker ps:

sudo docker ps CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES 

Nothing appears, because I restarted the machine and I didn't configure them to start the containers automatically.

So when I try to run a 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'. 

So I would like to see which Docker containers are already installed and start them.

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

Info of Container

To show running Containers. With -a option, it shows running and stopped Containers.

docker ps

like image 634
lapinkoira Avatar asked Jul 19 '16 08:07

lapinkoira


People also ask

How do I list a stopped container in docker?

List Stopped Containers. Stopped containers are those containers that are in exited state. Containers are put into exited state by executing the Docker stop command in them. If you want to list only the stopped containers, you can use the --filter option with a parameter called status.

How can I see all running docker containers?

In order to list the Docker containers, we can use the “docker ps” or “docker container ls” command. This command provides a variety of ways to list and filter all containers on a particular Docker engine.

How do you list both running containers and stopped or exited containers?

Using “docker ps” command :docker ps command provides an option –all or -a to display all containers i.e. both running and stopped containers. It displayed both the running and stopped containers. We can confirm that by checking STATUS column, it contains both up (running) and exited status in above output.


1 Answers

Like you said docker ps -a will show stopped and running containers (all the containers). The following command will only show you the stopped containers.

docker ps -a | grep Exit 

Now your able to perform docker logs container-id on your container to see what is going wrong.

like image 83
lvthillo Avatar answered Sep 28 '22 03:09

lvthillo