A Docker cheat sheet is a set of notes used for quick reference while using Docker in the real world. Below is the Docker cheat sheet that includes an extensive list of Docker commands. You can use it as a quick reference guide when working with Docker.
docker container run -d -p [host-port]:[container-port] image-name
Run a container and publish a container port
docker container run –rm image-name
Run a container that automatically removes a container when it exits
Copy a File Between Container and Host
docker cp container-name:/file/path /host/path
Copy 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 images
List all Docker images
docker tag oldname:tag newname:tag
Rename an image
docker search image-name
Search available images on the Docker Hub
docker history image-name
Check command history of any image
docker build -t image-name Dockerfile
Build an Image from Dockerfile
Docker Registry and Repository
docker login
Login to Docker registry
docker logout
Logout from a Docker registry
docker search image-name
Search an image from the Docker registry
docker pull myimage:tag
Pull an image from a registry
docker push myrepo/myimage
Push an image to registry
Import and Export Container and Image
docker save -o image.tar image-name
Export an image to a TAR archive
docker load < image.tar
Import an image from a TAR archive
docker commit container-name image-name
Create an image from a container
docker export container-name > container.tar
Export a container to a TAR archive
docker import container-name < container.tar
Import a container from TAR archive
Remove Container, Image, Network and Volume
docker container rm container-name
Remove a stopped container
docker container prune -f
Remove all stopped container
docker rmi image-name
Remove an unused Docker image
docker rmi $(docker images -a -q)
Remove all unused Docker images
docker image prune -a
Remove all dangling images
docker system prune -af
Remove unused and dangling images, networks, containers, and volumes
docker volume rm volume-name
Remove a Docker volume
docker network rm network-name
Remove 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.
Reading your article has greatly helped me, and I agree with you. But I still have some questions. Can you help me? I will pay attention to your answer. thank you.
Reading your article has greatly helped me, and I agree with you. But I still have some questions. Can you help me? I will pay attention to your answer. thank you.