DevOpsDockersHow to

The list container command

The indication of a running container can be shown using the following command:

# Usage: docker container ls [OPTIONS]docker container ls

This is the list containers command, and without any additional parameters, it will list the currently-running containers. What do I mean by currently running? A container is a special process running on the system, and like other processes on the system, a container can stop or exit. However, unlike other types of processes on your system, the default behavior for a container is to leave behind its read/write layer when it stops. This is because you can restart the container if desired, keeping the state data it had when it exited. As an example, imagine you run a container that is an OS, such as Ubuntu, and in that container you install wget. After the container exits, you can restart it, and it will still have wget installed. Remember that each running container has its own read/write layer, so, if you run one Ubuntu container and install wget, then you run another Ubuntu container, it will not have wget. The read/write layers are not shared between containers. However, if you restart a container that had the wget installed, it will still be installed.

So, the difference between a running container and a stopped one is that the process is either running or it has exited, leaving behind its own read/write layer. There is a parameter to the list containers command that allows you to list all of the containers, both those running and those that have exited. As you may have guessed, it is the –all
parameter, and it looks like this:

# short form of the parameter is -a
docker container ls -a
# long form is --all
docker container ls --all
# old syntax
docker ps -a

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

C7eDh

Please type the text above:

Close
Close