Day 20 - Docker Cheat-Sheet

๐ Welcome to the world of DevOps with Aakash! ๐
Hey tech enthusiasts! ๐ I'm Aakash, a dedicated freelance Linux System Admin @xFusionCorp, and I'm on a mission to conquer the world of DevOps. Currently, I'm immersed in building exciting projects and sharing my learning experiences with you all.
๐ ๏ธ My Tech Arsenal:
- Docker
- Linux
- Kubernetes
- Jenkins
- AWS
- Python
- Java
- Prometheus
- Grafana
- Ansible
- Terraform
Join me in navigating the intricate realms of AWS DevOps technology. Let's embrace learning with gratitude and thrive in this ever-evolving landscape!
๐ค Connect with me for:
- Friendly chats
- Shared experiences
- Learning moments
Follow my journey on Twitter and Linkedin for daily insights and tech goodness. Let's build, automate, and innovate our way through the exciting world of DevOps! ๐ #DevOps #AWS #TechEnthusiast #InnovationJourney #90DaysOfDevOps
Introduction
Welcome DevOps enthusiasts and learners. In this blog we're gonna get our hands dirty and sum up all the concepts that we have learnt in the past few days about docker. We are going to create our very own cheat sheet for our future revisions and references.
From Day 16 to Day 19, we're gonna sum up every concepts and create a comprehensive cheat-sheet for ourselves. So without delaying, let's just begin.
Commands
Here's the cheat-sheet of Docker commands according to the tasks they perform:
To pull an Image from Docker Hub:
docker pull <image_name>:versionTo run a container:
docker run <image_name>Flags for running a container:
-d: to run in backgroundTo inspect a container:
docker inspect <container_name>List of Running Containers:
docker psList all the containers (Running or stopped):
docker ps -aList of images on the system:
docker imagesDocker Port Mapping:
docker run -p host_port:container_port <image_name>Map a volume:
docker run -v HOSTDIR:TARGETDIR <image_name>To assign a name to the container while running:
docker run --name Name <Image_name>To stop a container:
docker stop <container_name_or_id>To start a stopped container:
docker start <container_name_or_id>To kill a container:
docker kill <container_name_or_id>To remove a container:
docker rm <container_name_or_id>Delete a running container:
docker rm -f <container_name_or_id>Copy files from container to host:
docker cp <container_name>:<file_name> <file_name>Copy files from host to container:
docker cp <file_name> <container_name>:<file_source>Run a command inside a running container:
docker exec -it <container_name> <name_of_shell>Create an image out of a container:
docker commit <container_name_or_id>To delete an image:
docker rmi <image_name>To delete all images:
docker image prune -aTo remove unused resources (container, Images, etc.):
docker system pruneBuild an image from Dockerfile:
docker build DOCKERFILEBuild and tag the image at the same time:
docker build -t <Name> <DockerFile> .Tag an image:
docker tag <image_id_or_name> <new_tag>To connect with your Docker Hub account:
docker login <registry_url>/<repository_name>:<tag>Push an image to Docker Hub:
docker push <registry_url>/<repository_name>:<tag>See Logs of container:
docker logs <Container_name_or_id>See Modified files in a container:
docker diff <Container_name>See the stats of the running container:
docker statsDelete Stopped containers:
docker containers pruneRename a container:
docker rename <Old_name> <New_Name>Save an image to a tar file:
docker save <Image> > FILE.tarLoad an image from a tar file:
docker load -i FILE.tar
Conclusion
In this cheat sheet, we covered the extensive set of Docker commands needed to manage containers, images, volumes, and more. Whether you're a beginner Docker installer or an experienced user looking to simplify your workflow, these commands provide intuitive tutorials for tasks ranging from running containers to images managing types to connectivity and troubleshooting.
By getting these commands right, you can effectively deploy, monitor, and maintain them, empowering you to use the full power of Docker in your development and deployment planning. With the knowledge in this cheat sheet, you're ready to enter the world of containerization with confidence.
I hope this blog added some Value to your learning. Do curate and share your own chat-sheet on LinkedIn and don't forget to tag me.
Ending this with a quote
Every great developer you know got there by solving problems they were unqualified to solve until they actually did it. - Patrick McKenzie
Happy Learning.





