Skip to main content

Command Palette

Search for a command to run...

Untwist the world of Docker - P3

Updated
5 min read
Untwist the world of Docker - P3
Y

As a final year undergraduate with a passion for Cloud DevOps Engineering, I bring a strong foundation in cloud computing and automation to the table. I have a solid understanding of cloud platforms such as AWS or Google Cloud and have honed my skills in infrastructure as code (IaC) using tools like Terraform and CloudFormation. I am eager to apply my knowledge of CI/CD pipelines, containerization, and version control systems to contribute to efficient and automated software development processes. I am a quick learner, highly motivated, and excited to embark on a career in Cloud & DevOps, where I can leverage my technical expertise to drive innovation and streamline operations.

In addition to my proficiency in cloud technologies, I bring a wealth of experience in crafting efficient CI/CD pipelines, implementing containerization strategies, and managing version control systems. My eagerness to learn, coupled with my inherent motivation, fuels my drive to continually enhance processes and drive innovation in software development.

I am poised to make a significant impact in Cloud, DevOps and DevSecOps leveraging my technical prowess to streamline operations and catalyze organizational growth.

Well i am a part-time competitive Coder too, I have a solid understanding of Data Structure and Algorithms as well as of Object Oriented Programming. I usually code in C++ and have the familiarity with Java and Python as well as i also have the intermediate knowledge of Rust Programming language too. Some of my coding achievements are 5🌟 @HackerRank || 4🌟 @CodeChef(Max.Rating->1845) || Knight🔰 @LeetCode(Max.Rating->1858).

Along with all these stuffs i have the understanding of Cloud Platforms like Amazon Web Services (AWS) and Google Cloud Platform (GCP). I was also a Google Cloud's Arcade Facilitator in 2k23 where i had mentored 150+ student's and professional's in gaining knowledge about the Google Cloud Platform (GCP). Moreover I had also won some of the Google Cloud's events like Google CRFP'22 || Google CCP'23.

So, before moving ahead in this series of Docker and start discussing about the various examples of Dockerfiles, creating Docker Images using Dockerfiles and pushing it to Registry i.e. Docker Hub, Creating Docker Containers, etc.

Today, let's see the ultimate Docker Cheat sheet. A cheat sheet is a concise summary of important information that is meant to be used as a quick reference. In the context of Docker, a Docker cheat sheet is a summary of commonly used Docker commands and their options, as well as other useful information related to Docker. Cheat sheets can be helpful when learning a new tool or technology, as they provide a convenient way to quickly look up and remind ourself of key concepts and commands.

LET'S BEGIN WITH DOCKER'S ULTIMATE CHEAT SHEET:

Command to view the Docker's Version:

docker --version

Command for logging in into the Docker Hub on the webserver like: Linux, Ubuntu, etc.:

docker login

Command for run a new container from an Docker Image:

docker run <Image Name>

// exmaple
docker run hello-world

Command for start a new container from an Docker Image and assigning it a name:

docker run --name CONTAINER_IMAGE

// exmaple
docker run --name web hello-world

Command for start a new container from an Docker Image and run container in background:

docker run -d <Image Name>

// exmaple
docker run -d hello-world

Command for start a new container from an Docker Image and run container in background and assign it a hostname:

docker run --hostname <HOSTNAME> <Image Name>

// exmaple
docker run --hostname steve hello-world

Command for start a new container from an Docker Image and map a Port to it:

docker run -p <HOSTPORT>:<CONTAINER PORT> <Image Name>

// exmaple
docker run -p 8080:80 hello-world

Command for start a new container from an Docker Image and map all the Port to it:

docker run -P <Image Name>

// exmaple
docker run -P hello-world

Command for start a new container from an Docker Image and run container in background and add a DNS entry:

docker run --add-host <HOSTNAME>:<Image IP>

Command for start a new container from an Docker Image but change the entry point:

docker run -it --entrypoint <EXECUTABLE IMAGE>

// exmaple
docker run -it --entrypoint bash hello-world

Command to view the list of a running Docker Container:

docker ps

Command to view the list of all running Docker Container:

docker ps -a

Command to stop a Docker Container:

docker stop <CONATINER NAME> or <CONATINER ID>

//example
docker stop sonarqube or e2g54umof0

Command to remove a Docker Container:

docker rm <CONATINER NAME> or <CONATINER ID>

//example
docker rm sonarqube or e2g54umof0

Command to remove a running Docker Container:

docker rm -f <CONATINER NAME> or <CONATINER ID>

//example
docker rm -f sonarqube or e2g54umof0

Command to start a stopped Docker Container:

docker start <CONATINER NAME> or <CONATINER ID>

//example
docker start sonarqube or e2g54umof0

Command to copy a file from a Docker Container to the Host:

docker cp <CONATINER NAME>:<SOURCE> <TARGET>

//example
docker start website:/index.html index.html

Command to copy a file from a Host to Docker Container:

docker cp <TARGET> <CONATINER NAME>:<SOURCE> 

//example
docker start index.html website:/index.html

Command to start a shell inside a running Docker Container:

docker run -it <CONATAINER> <EXECUTABLE NAME>

// exmaple
docker run -it website bash

Command to rename a Docker Container:

docker rename <OLD NAME> <NEW NAME>

// exmaple
docker run -it website king

Command to create an image out of Docker Container:

docker commit <CONTAINER NAME>

// exmaple
docker commit king

Command to download an Docker Image:

docker pull <IMAGE NAME>:<TAG>

// exmaple
docker pull nginx:latest

Command to push an Docker Image to Docker Hub:

docker push <IMAGE NAME>

// exmaple
docker push joker:1.0

Command to delete an Docker Image:

docker rmi <IMAGE NAME>

// exmaple
docker rmi joker

Command to view a list of all the Docker Images:

docker images

Command to remove all the dangling Docker Images:

docker image prune

Command for building a Docker Image using Dockerfile:

docker build <IMAGE NAME> .

//example
docker build netflix .

Command for Tagging a Docker Image:

docker tag <IMAGE NAME> <NEW IMAGE NAME>

//example
docker tag netflix netflix:19.0

Command for building a Docker Image using Dockerfile and Tagging it:

docker build -t <IMAGE DIRECTORY>

//example
docker build netflix:19.0 .

Command for saving a Docker Image to TAR file:

docker save <IMAGE> > <FILE NAME>

//example
docker save netflix > netflix.tar

Command for loading a Docker Image from a TAR file:

docker load -i <TAR FILE NAME>

//example
docker load -i netflix.tar

Command to view all logs of a Docker Container:

docker logs <CONTAINER NAME>

// exmaple
docker logs netflix

Command to view stats of running Docker Containers:

docker stats

Command to view processes of a running Docker Container:

docker top <CONTAINER NAME>

// exmaple
docker top netflix

Command to get detailed information of an object of Docker Image:

docker inspect <IMAGE NAME>

// exmaple
docker inspect netflix

Command to view all the modified files in a Docker Container:

docker diff <CONTAINER NAME>

// exmaple
docker diff netflix

Command to view all the mapped ports of a Docker Container:

docker port <CONTAINER NAME>

// exmaple
docker port netflix

So, this is the Ultimate Cheat Sheet for Docker which contains all the useful commands for Docker.

So finally, In the next part we will be seeing the various examples of creating Dockerfiles, creating Docker Images and pushing it to Registry i.e. Docker Hub.

More from this blog

Untitled Publication

39 posts