Working with Docker 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.
THE VALLEY OF CODE
THE WEB DEVELOPER's MANUAL
You might be interested in those things I do:
- Learn to code in THE VALLEY OF CODE, your your web development manual
- Find a ton of Web Development projects to learn modern tech stacks in practice in THE VALLEY OF CODE PRO
- I wrote 16 books for beginner software developers, DOWNLOAD THEM NOW
- Every year I organize a hands-on cohort course coding BOOTCAMP to teach you how to build a complex, modern Web Application in practice (next edition February-March-April-May 2024)
- Learn how to start a solopreneur business on the Internet with SOLO LAB (next edition in 2024)
- Find me on X