Basic Docker Commands
Docker is an open-source tool that streamlines application deployment through independent, portable containers, adaptable to both local and cloud environments. This separation of applications from infrastructure facilitates swift software delivery and uniform management practices. Docker commands are pivotal in containerization, empowering developers to construct, deploy, and manage applications efficiently. By encapsulating dependencies in self-contained units, these commands ensure consistent and reliable deployment. They enhance software management, fostering shorter development cycles, scalability, and portability across diverse environments. This concise guide illuminates the significance of Docker commands, offering a comprehensive list with illustrative examples for seamless application orchestration and deployment.
Basic Docker Commands
Let's take a look at the most commonly used docker commands.
docker - version
This docker command is used to output the currently installed version and build several dockers.
Example :
Scaler Placement Report and Statistics
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
docker pull
This docker command is used to pull images from a docker repository.
Example :
docker run
This docker command is used to start a docker container from a docker image.
Example :
Transform Your Career
Choose from our industry-leading programs designed for career success
Modern Software and AI Engineering Program
Master full-stack development with AI integration
+1000 moreModern Data Science and ML with specialisation in AI
Advanced data science techniques with AI specialization
+1000 moreAdvanced AIML with Specialisation in Agentic AI
Deep dive into AIML with focus on Agentic systems
+1000 moreDevOps, Cloud & AI Platform Engineering
Build and manage AI-powered cloud infrastructure
+1000 moreAI Engineering Advanced Certification by IIT-Roorkee
Premier AI engineering certification from IIT-Roorkee
docker ps
This docker command is used to output a list of containers currently running inside the docker engine.
Example :
docker ps -a
This docker command is used to output a list of containers currently existing inside the docker engine in the running or stopped state.
Example :
docker exec
This docker command is used to access a shell inside the running container.
Example :
Scaler Placement Report and Statistics
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
docker stop
This docker command is used to stop a running container.
Example :
docker restart
This docker command is used to restart a container Example :
docker kill
This docker command is used to terminate a container immediately.
Example :
'docker kill' and 'docker stop' perform the same action of terminating a container. But, ‘docker stop’ gives the container time to shut down gracefully, whereas 'docker kill' terminates a container immediately.
Turn Learning into Career Growth
docker commit
This docker command is used to create a new image of an edited container on the local system.
Example :
docker push
This docker command is used to push an image into a docker repository.
Example :
docker login
This docker command is used to login into a docker repository.
Example :
docker images
This docker command is used to list all the docker images stored on the machine.
Example :
docker rm
This docker command is used to delete a stopped container.
Example :
docker rmi
This docker command is used to delete a locally stored docker image.
Example :
docker build
This docker command is used to build a docker image based on the instructions specified in a Dockerfile.
Example :
Conclusion
We have taken a look over the most commonly used docker commands. Sound knowledge of these Docker commands will give you the needed expertise to work and experiment with Docker. So, practice them!
Let's continue learning about docker and its concepts with other docker-related articles.