To list all the running docker containers, use this command –
docker ps
and use this command to list all the containers running or otherwise –
docker ps -a
Different Container States
Suppose no container is running in your system, then docker ps
command will return an empty table as shown in the image –
In this situation we might need to know about all the containers which are stopped. docker ps -a
will return all of them, no matter whether they are running or stopped. Check out the image below –
You can see that the command displayed a list of many containers. They are all in exited state.
If a container is running then the outputs are –
For docker ps
–
For docker ps -a
–
Understanding Response
Let us understand the response return by the command. It’s a table of columns –
-
CONTAINER ID
– This is a 12 digit unique alphanumeric id which is assigned by docker to each container. This id is used to start/stop a container. -
IMAGE
– It’s the name of the image for which the container is running. -
COMMAND
– This is the entrypoint command which is listed in Dockerfile of image. This command runs when a container gets live. -
CREATED
– This shows the time when the container was created. -
STATUS
– The current status of container (Up or Exited). Along with that it shows the time when it attained this status. -
PORTS
– The ports which are exposed in the container. -
NAMES
– A human readable name for container. You can do everything using this name what you can do with container id.
Kubernetes Series
- Introduction to Kubernetes
- Introduction to Docker, Containers, Images & Repository
- Install and Run Docker Images
- Docker Image – FROM, RUN, COPY, ENTRYPOINT, CMD, EXPOSE explained
- Why docker run or start command not running my container?
- How to list all docker images in system?
- How to list all docker containers?
- How to start/stop a docker container?
- Difference between docker run and docker start
- How to bind docker container port with host?
- How to get logs of docker container?
- How to live stream logs of docker container?
- Set custom name to a docker container
- Access docker container filesystem & terminal
- Getting docker details using docker inspect
- Kyverno – Installation, Policies, Testing, Reporting, Monitoring, Security
- Complete Kubernetes Project Step By Step
- Introduction to Kubernetes Objects