Skip to content
FLAVIO COPES
flaviocopes.com
2026

Working with Docker Containers from the command line

By Flavio Copes

Learn how to work with Docker containers from the command line, using docker ps to list them and docker container stop, rm, and inspect to manage them.

~~~

The Docker Desktop application is awesome to work with containers locally via a graphical interface.

You are not required to use it. You can use the CLI commands.

The docker ps command lists the currently running containers:

Terminal output showing docker ps command listing a running container named node-app with ID, status, and port mapping

This is the same as running docker container ls.

In this case, container with name node-app and ID 739037a911e0 generated from the image examplenode, created 4 minutes ago, is up since 4 minutes, and the port 80 of the host machine is mapped to the container port 3000 using the TCP protocol.

When you know the contained ID, you can stop the container by running

docker container stop <ID>

Terminal showing docker container stop command being executed to stop a running container

Once a container is stopped, you can see it using docker container ls -a:

Terminal output of docker container ls -a command showing stopped containers with Exited status

And you can remove it using docker container rm:

docker container rm <ID>

You can inspect all the details about a container running docker inspect:

Terminal displaying docker inspect command output showing detailed JSON configuration of a container

Another useful CLI command is docker info which gives you lots of information about the current state of your Docker installation, including the number of containers and images.

Terminal output of docker info command showing Docker installation details including containers, images, and server version

Tagged: Docker ยท All topics
~~~

Related posts about docker: