Originally published on CodingCush.

This Docker commands cheat sheet gives you the 25 commands beginners actually use every day: pulling and building images, starting and stopping containers, saving data in volumes, connecting containers with networks, checking logs, and cleaning up safely. You do not need to memorise hundreds of options. Learn these 25 well, understand what each one does, and you can run most small projects, follow most tutorials, and fix most beginner problems without panic. Bookmark this page, try each command on a practice project, and soon your fingers will type them before your brain has finished complaining.

How to Use This Cheat Sheet

Every command below follows the same pattern: the word docker, the thing you want to work on, and the action. Names such as web, my-app and app-data are examples, so replace them with your own names. Angle brackets are never typed. If Docker itself is still new to you, first read our friendly guide to what Docker is and how it works, then return here with a terminal open. The official Docker CLI reference lists every option when you need more detail.

One safety habit matters from day one. Read a command before pressing Enter, especially commands that remove things. Docker is helpful, but it is also very obedient. If you tell it to delete the wrong container, it will do so politely and instantly.

Docker Image Commands

Images are the templates containers are made from. If that sentence still feels fuzzy, our comparison of Docker image vs container differences explains it with a simple analogy. These five commands cover the full image life cycle.

1. docker pull downloads an image from a registry such as Docker Hub, so you can use it locally.

docker pull nginx:latest 

2. docker images lists the images already on your machine, with their tags and sizes. It is the quickest way to check what you have.

docker images 

3. docker build creates an image from a Dockerfile in the current folder. The -t flag gives the image a name and tag.

docker build -t my-app:1.0 . 

4. docker tag adds another name or version label to an existing image, which is useful before sharing it.

docker tag my-app:1.0 my-app:latest 

5. docker rmi removes an image you no longer need. Docker will refuse if a container still uses it, which is a useful safety net.

docker rmi my-app:1.0 

Docker Container Commands

Containers are where your app actually runs. These seven commands start, view, control and remove them.

6. docker run creates and starts a container. The -d flag runs it in the background, -p maps a port, and --name gives it a friendly name.

docker run -d -p 8080:80 --name web nginx 

7. docker ps shows running containers. Add -a when you also want stopped ones, which is where missing containers usually hide.

docker ps -a 

8. docker stop shuts a container down gently, giving the app a moment to finish its work.

docker stop web 

9. docker start starts a stopped container again, keeping its settings and files.

docker start web 

10. docker restart stops and starts a container in one step, a classic move after changing a setting.

docker restart web 

11. docker exec runs a command inside a running container. With -it and a shell, you can look around inside it.

docker exec -it web sh 

12. docker rm deletes a stopped container. Add the name of a container you have finished with, and it is gone.

docker rm web 

Docker documentation What is Docker page on docs.docker.com explaining the Docker platform and containers

The What is Docker page of the Docker documentation on docs.docker.com.

Volume and Network Commands

Containers are temporary by design, so data that must survive belongs in a volume. Networks let containers talk to each other by name, like small computers on a private office network.

13. docker volume create makes a named volume for permanent data such as a database.

docker volume create app-data 

14. docker volume ls lists your volumes, so you can confirm a name before using it.

docker volume ls 

15. docker network create makes a private network for a group of containers.

docker network create app-net 

16. docker network ls lists all networks on your machine, including the default ones Docker creates for you.

docker network ls 

When you start containers on the same custom network, they can reach each other using container names. That one idea removes a lot of beginner confusion about addresses and ports.

Inspecting and Troubleshooting Commands

Things will break. A port will clash, a container will exit, and an app will say nothing useful at all. These four commands are your torch in that dark room. The Docker overview in the official documentation also explains how the parts fit together when you want the bigger picture.

17. docker logs shows what a container has printed. Add -f to follow new lines as they arrive.

docker logs -f web 

18. docker inspect prints detailed information about a container, image, volume or network as structured data, including settings you may have forgotten.

docker inspect web 

19. docker stats shows live CPU, memory and network use for running containers, which helps you spot one greedy container.

docker stats 

20. docker cp copies a file between your computer and a container, handy for grabbing a log file or testing a quick config change.

docker cp web:/etc/nginx/nginx.conf ./nginx.conf 

Docker Compose and Cleaning Up

Compose commands manage multi container projects defined in one file, and prune commands remove unused Docker objects. Use the prune family carefully, because removed objects do not come back with an apology.

21. docker compose up builds and starts every service in your Compose project. The -d flag keeps them in the background.

docker compose up -d 

22. docker compose down stops that project and removes its containers and network, while keeping named volumes by default.

docker compose down 

23. docker container prune deletes all stopped containers, which is a quick way to tidy a messy practice machine.

docker container prune 

24. docker image prune removes unused images that are not linked to a container.

docker image prune 

25. docker system prune is the big broom: it clears stopped containers, unused networks and dangling images in one go. Read its confirmation prompt slowly before saying yes.

docker system prune 

Quick Summary Table

Job Command Use it to
Images docker pull Download an image
Images docker images List local images
Images docker build Build from a Dockerfile
Images docker tag Add a version label
Images docker rmi Remove an image
Containers docker run Start a new container
Containers docker ps List containers
Containers docker stop Stop a container gently
Containers docker start Start a stopped container
Containers docker restart Restart a container
Containers docker exec Work inside a container
Containers docker rm Delete a stopped container
Data docker volume create Create permanent storage
Data docker volume ls List volumes
Networks docker network create Create a network
Networks docker network ls List networks
Checking docker logs Read container output
Checking docker inspect See full details
Checking docker stats Watch resource use
Checking docker cp Copy files across
Projects docker compose up Start a full project
Projects docker compose down Stop a full project
Cleaning docker container prune Remove stopped containers
Cleaning docker image prune Remove unused images
Cleaning docker system prune Do a broad clean up

Frequently Asked Questions

Do I need to learn all Docker commands?

No. Most daily work uses a small core set like the 25 here. Learn those first, then add specialist commands only when a real project needs them.

What is the difference between docker stop and docker rm?

Stop only halts a container, so you can start it again later. Remove deletes the stopped container itself, although its image and named volumes remain.

Why did my container disappear from docker ps?

It probably stopped. The plain list only shows running containers, so check the list with -a to see stopped ones, then read its logs for the reason.

Are prune commands safe for beginners?

They are safe when you understand them and dangerous when you rush. They remove unused objects permanently, so check your containers, images and volumes first, especially on a shared machine.

Conclusion

You now have a practical Docker toolkit: five image commands, seven container commands, four volume and network commands, four checking commands, and five Compose and cleaning commands. Practise them on a throwaway project, break something small, and fix it with logs and inspect. That honest little loop teaches faster than rereading any list, including this one. Keep this cheat sheet nearby for your first few projects, and very soon you will only return for the commands you use once a month.