The Ultimate Docker Cheat Sheet – Quick Reference

docker cheat sheet

A Docker cheat sheet is a set of notes used for quick reference while using Docker in the real world. I have prepared a Docker cheat sheet that includes an extensive list of Docker commands.

Here, I am presenting my Docker Cheat Sheet (a one-page guide) with all common terms and useful one-liners commands. You can use it as a quick reference guide when working with Docker. If you want to learn more about Docker with detail information and examples, you can read the rest of the article.

If you want to host Docker on Cloud and don’t know how to choose the best Cloud hosting provider. You can read my guide on The 8 Best Docker Hosting Platforms in 2022.

Docker Basic Commands
COMMANDSDESCRIPTIONS
systemctl start dockerStart Docker service
systemctl restart dockerRestart Docker service
systemctl enable dockerEnable Docker to start at reboot
systemctl status dockerCheck Docker service status
docker –versionCheck Docker version
docker infoPrint Docker information in detail
docker system dfCheck disk space being used by your containers
Docker Container Commands
docker ps Or docker container lsList only running containers
docker ps -a Or docker container ls -aList both running and stopped containers
docker ps -lList the latest created containers
docker ps -sList all containers by their size
docker ps -qaList all containers by their ID
docker statsShow running container stats
docker start container-nameStart a container
docker restart container-nameRestart a container
docker stop container-nameStop a container
docker stop $(docker ps -aq)Stop all running container
docker exec -it container-name /bin/bashSSH into container
docker logs container-nameCheck log of a container
docker top container-nameCheck the running process in a container
docker inspect -f “{{ .NetworkSettings.IPAddress }}” container-nameCheck the IP address of a container
docker container rename oldname newnameRename a container
Docker Run Commands
docker container run –name container imageRun a container from an image
docker container run -d image-nameRun a container in detached mode
docker container run -it image-name /bin/bashRun a container in interactive mode
docker container run -d -p [host-port]:[container-port] image-nameRun a container and publish a container port
docker container run –rm image-nameRun a container that automatically removes a container when it exits
Copy a File Between Container and Host
docker cp container-name:/file/path /host/pathCopy a file from container to host
docker cp /host/file/path container-name:/path/Copy a file from host to container
Docker Image Commands
docker imagesList all Docker images
docker tag oldname:tag newname:tagRename an image
docker search image-nameSearch available images on the Docker Hub
docker history image-nameCheck command history of any image
docker build -t image-name DockerfileBuild an Image from Dockerfile
Docker Registry and Repository
docker loginLogin to Docker registry
docker logoutLogout from a Docker registry
docker search image-nameSearch an image from the Docker registry
docker pull myimage:tagPull an image from a registry
docker push myrepo/myimagePush an image to registry
Import and Export Container and Image
docker save -o image.tar image-nameExport an image to a TAR archive
docker load < image.tarImport an image from a TAR archive
docker commit container-name image-nameCreate an image from a container
docker export container-name > container.tarExport a container to a TAR archive
docker import container-name < container.tarImport a container from TAR archive
Remove Container, Image, Network and Volume
docker container rm container-nameRemove a stopped container
docker container prune -fRemove all stopped container
docker rmi image-nameRemove an unused Docker image
docker rmi $(docker images -a -q)Remove all unused Docker images
docker image prune -aRemove all dangling images
docker system prune -afRemove unused and dangling images, networks, containers, and volumes
docker volume rm volume-nameRemove a Docker volume
docker network rm network-nameRemove a Docker network

Conclusion

In the above Docker Cheat Sheet, you learned all docker commands with a brief description. You can now use this Docker Cheat Sheet as a quick reference guide when working with Docker.

To learn more about Docker check out my all published docker-tutorial

Recommended Reading

About Hitesh Jethva

I am Hitesh Jethva Founder and Author at LinuxBuz.com. I felt in love with Linux when i was started to learn Linux. I am a fan of open source technology and have more than 15+ years of experience in Linux and Open Source technologies.

View all posts by Hitesh Jethva