Bootstrap FreeKB - Docker - List containers using the docker container ls command
Docker - List containers using the docker container ls command

Updated:   |  Docker articles

This assumes you have installed Docker on Linux and Docker is running.

A Docker image contains the code used to create a Docker container, such as creating a Nginx web server, or a mySQL server, or a home grown app, and the list goes on. In this way, an image is like a template used to create a container. An image is kind of like a virtual machine, but much more light weight, using significantly less storage a memory (containers are usually megabytes in size).

The docker container ls command will return the list of containers.

docker container ls

 

Which will return something like this. If the container was created but not yet started, the status of the container will be "created".

CONTAINER ID     IMAGE              COMMAND                 CREATED         STATUS     PORTS     NAMES
d937372c09ab9    b939aa938add9913   "/docker-entrypoin..."  6 minutes ago   Created              my-container

 

After using the docker start command to start the container, the status of the container should either be "up xxx" or "exited". If the container is up, the socket (ip address:port) being used by the container will be displayed. If the status is "exited", use the docker logs command to determine why the container failed to start.

CONTAINER ID     IMAGE              COMMAND                 CREATED       STATUS        PORTS     NAMES
d937372c09ab9    b939aa938add9913   "/docker-entrypoin..."  6 minutes ago Up 30 seconds 0.0.0.0:12345->12345/tcp

 

If the status of the container is "Exited (1)", attempt to start the container using the docker start command. If the container still has a status of Exited, check the docker logs.




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 75c091 in the box below so that we can be sure you are a human.