Docker Advanced: Working with Containers from the command line

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:

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>

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

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:

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.

Lessons in this unit:

0: Introduction
1: Working with Images from the command line
2: ▶︎ Working with Containers from the command line
3: Troubleshooting container exits
4: How to commit changes to an image
5: Updating a deployed container
6: Accessing files outside a container
7: Dockerfile for Astro on Fly.io
8: Dockerfiles for Astro and Pocketbase on Railway

Join my AI Workshop!

The Web Development BOOTCAMP cohort starts in February 2026