Essential Docker Commands
The everyday Docker commands for running, listing, stopping, removing, and inspecting containers and images.
Docker has many commands, but beginners should first become comfortable with the commands used every day.
These commands help you run containers, check what is running, view images, inspect logs, stop containers, and clean up after practice.
Check Docker installation
Start with:
docker version
docker infodocker version shows the client and server versions. docker info shows details about the Docker Engine, storage driver, running containers, images, and system configuration.
If these commands work, your terminal can talk to Docker.
Run a container
Use docker run to create and start a container from an image.
docker run hello-worldIf the image is not available locally, Docker downloads it first.
To run an Nginx web server:
docker run nginxThis starts the container in the foreground, so logs appear directly in the terminal.
List running containers
To see running containers:
docker psTo see all containers, including stopped ones:
docker ps -aThis is one of the most useful Docker commands. Use it often.
List images
To see images available on your machine:
docker imagesImages stay on your system until you remove them. Running a container does not automatically delete the image.
Stop and remove containers
Stop a running container:
docker stop container-idRemove a stopped container:
docker rm container-idYou can use either the container ID or container name.
Remove images
To remove an image:
docker rmi image-nameIf a container is still using that image, Docker will not remove it. Remove the container first.
View container logs
To see logs from a container:
docker logs container-idThis is useful when an application starts but does not behave as expected.
Command summary
| Command | Purpose |
|---|---|
docker version | Check Docker client and server version |
docker run image | Create and start a container |
docker ps | Show running containers |
docker ps -a | Show all containers |
docker images | Show local images |
docker stop id | Stop a running container |
docker rm id | Remove a stopped container |
docker rmi image | Remove an image |
docker logs id | Show container logs |
Do not try to memorise every Docker command at once. Start with run, ps, images, stop, rm, and logs. These cover most beginner practice.
Written By: Shiva Srivastava
How is this guide?
Last updated on
