Explore Courses
course iconScrum AllianceCertified ScrumMaster (CSM) Certification
  • 16 Hours
Best seller
course iconScrum AllianceCertified Scrum Product Owner (CSPO) Certification
  • 16 Hours
Best seller
course iconScaled AgileLeading SAFe 6.0 Certification
  • 16 Hours
Trending
course iconScrum.orgProfessional Scrum Master (PSM) Certification
  • 16 Hours
course iconScaled AgileSAFe 6.0 Scrum Master (SSM) Certification
  • 16 Hours
course iconScaled Agile, Inc.Implementing SAFe 6.0 (SPC) Certification
  • 32 Hours
Recommended
course iconScaled Agile, Inc.SAFe 6.0 Release Train Engineer (RTE) Certification
  • 24 Hours
course iconScaled Agile, Inc.SAFe® 6.0 Product Owner/Product Manager (POPM)
  • 16 Hours
Trending
course iconKanban UniversityKMP I: Kanban System Design Course
  • 16 Hours
course iconIC AgileICP Agile Certified Coaching (ICP-ACC)
  • 24 Hours
course iconScrum.orgProfessional Scrum Product Owner I (PSPO I) Training
  • 16 Hours
course iconAgile Management Master's Program
  • 32 Hours
Trending
course iconAgile Excellence Master's Program
  • 32 Hours
Agile and ScrumScrum MasterProduct OwnerSAFe AgilistAgile CoachFull Stack Developer BootcampData Science BootcampCloud Masters BootcampReactNode JsKubernetesCertified Ethical HackingAWS Solutions Artchitct AssociateAzure Data Engineercourse iconPMIProject Management Professional (PMP) Certification
  • 36 Hours
Best seller
course iconAxelosPRINCE2 Foundation & Practitioner Certificationn
  • 32 Hours
course iconAxelosPRINCE2 Foundation Certification
  • 16 Hours
course iconAxelosPRINCE2 Practitioner Certification
  • 16 Hours
Change ManagementProject Management TechniquesCertified Associate in Project Management (CAPM) CertificationOracle Primavera P6 CertificationMicrosoft Projectcourse iconJob OrientedProject Management Master's Program
  • 45 Hours
Trending
course iconProject Management Master's Program
  • 45 Hours
Trending
PRINCE2 Practitioner CoursePRINCE2 Foundation CoursePMP® Exam PrepProject ManagerProgram Management ProfessionalPortfolio Management Professionalcourse iconAWSAWS Certified Solutions Architect - Associate
  • 32 Hours
Best seller
course iconAWSAWS Cloud Practitioner Certification
  • 32 Hours
course iconAWSAWS DevOps Certification
  • 24 Hours
course iconMicrosoftAzure Fundamentals Certification
  • 16 Hours
course iconMicrosoftAzure Administrator Certification
  • 24 Hours
Best seller
course iconMicrosoftAzure Data Engineer Certification
  • 45 Hours
Recommended
course iconMicrosoftAzure Solution Architect Certification
  • 32 Hours
course iconMicrosoftAzure Devops Certification
  • 40 Hours
course iconAWSSystems Operations on AWS Certification Training
  • 24 Hours
course iconAWSArchitecting on AWS
  • 32 Hours
course iconAWSDeveloping on AWS
  • 24 Hours
course iconJob OrientedAWS Cloud Architect Masters Program
  • 48 Hours
New
course iconCareer KickstarterCloud Engineer Bootcamp
  • 100 Hours
Trending
Cloud EngineerCloud ArchitectAWS Certified Developer Associate - Complete GuideAWS Certified DevOps EngineerAWS Certified Solutions Architect AssociateMicrosoft Certified Azure Data Engineer AssociateMicrosoft Azure Administrator (AZ-104) CourseAWS Certified SysOps Administrator AssociateMicrosoft Certified Azure Developer AssociateAWS Certified Cloud Practitionercourse iconAxelosITIL 4 Foundation Certification
  • 16 Hours
Best seller
course iconAxelosITIL Practitioner Certification
  • 16 Hours
course iconPeopleCertISO 14001 Foundation Certification
  • 16 Hours
course iconPeopleCertISO 20000 Certification
  • 16 Hours
course iconPeopleCertISO 27000 Foundation Certification
  • 24 Hours
course iconAxelosITIL 4 Specialist: Create, Deliver and Support Training
  • 24 Hours
course iconAxelosITIL 4 Specialist: Drive Stakeholder Value Training
  • 24 Hours
course iconAxelosITIL 4 Strategist Direct, Plan and Improve Training
  • 16 Hours
ITIL 4 Specialist: Create, Deliver and Support ExamITIL 4 Specialist: Drive Stakeholder Value (DSV) CourseITIL 4 Strategist: Direct, Plan, and ImproveITIL 4 Foundationcourse iconJob OrientedData Science Bootcamp
  • 6 Months
Trending
course iconJob OrientedData Engineer Bootcamp
  • 289 Hours
course iconJob OrientedData Analyst Bootcamp
  • 6 Months
course iconJob OrientedAI Engineer Bootcamp
  • 288 Hours
New
Data Science with PythonMachine Learning with PythonData Science with RMachine Learning with RPython for Data ScienceDeep Learning Certification TrainingNatural Language Processing (NLP)TensorflowSQL For Data Analyticscourse iconIIIT BangaloreExecutive PG Program in Data Science from IIIT-Bangalore
  • 12 Months
course iconMaryland UniversityExecutive PG Program in DS & ML
  • 12 Months
course iconMaryland UniversityCertificate Program in DS and BA
  • 31 Weeks
course iconIIIT BangaloreAdvanced Certificate Program in Data Science
  • 8+ Months
course iconLiverpool John Moores UniversityMaster of Science in ML and AI
  • 750+ Hours
course iconIIIT BangaloreExecutive PGP in ML and AI
  • 600+ Hours
Data ScientistData AnalystData EngineerAI EngineerData Analysis Using ExcelDeep Learning with Keras and TensorFlowDeployment of Machine Learning ModelsFundamentals of Reinforcement LearningIntroduction to Cutting-Edge AI with TransformersMachine Learning with PythonMaster Python: Advance Data Analysis with PythonMaths and Stats FoundationNatural Language Processing (NLP) with PythonPython for Data ScienceSQL for Data Analytics CoursesAI Advanced: Computer Vision for AI ProfessionalsMaster Applied Machine LearningMaster Time Series Forecasting Using Pythoncourse iconDevOps InstituteDevOps Foundation Certification
  • 16 Hours
Best seller
course iconCNCFCertified Kubernetes Administrator
  • 32 Hours
New
course iconDevops InstituteDevops Leader
  • 16 Hours
KubernetesDocker with KubernetesDockerJenkinsOpenstackAnsibleChefPuppetDevOps EngineerDevOps ExpertCI/CD with Jenkins XDevOps Using JenkinsCI-CD and DevOpsDocker & KubernetesDevOps Fundamentals Crash CourseMicrosoft Certified DevOps Engineer ExperteAnsible for Beginners: The Complete Crash CourseContainer Orchestration Using KubernetesContainerization Using DockerMaster Infrastructure Provisioning with Terraformcourse iconTableau Certification
  • 24 Hours
Recommended
course iconData Visualisation with Tableau Certification
  • 24 Hours
course iconMicrosoftMicrosoft Power BI Certification
  • 24 Hours
Best seller
course iconTIBCO Spotfire Training
  • 36 Hours
course iconData Visualization with QlikView Certification
  • 30 Hours
course iconSisense BI Certification
  • 16 Hours
Data Visualization Using Tableau TrainingData Analysis Using Excelcourse iconEC-CouncilCertified Ethical Hacker (CEH v12) Certification
  • 40 Hours
course iconISACACertified Information Systems Auditor (CISA) Certification
  • 22 Hours
course iconISACACertified Information Security Manager (CISM) Certification
  • 40 Hours
course icon(ISC)²Certified Information Systems Security Professional (CISSP)
  • 40 Hours
course icon(ISC)²Certified Cloud Security Professional (CCSP) Certification
  • 40 Hours
course iconCertified Information Privacy Professional - Europe (CIPP-E) Certification
  • 16 Hours
course iconISACACOBIT5 Foundation
  • 16 Hours
course iconPayment Card Industry Security Standards (PCI-DSS) Certification
  • 16 Hours
course iconIntroduction to Forensic
  • 40 Hours
course iconPurdue UniversityCybersecurity Certificate Program
  • 8 Months
CISSPcourse iconCareer KickstarterFull-Stack Developer Bootcamp
  • 6 Months
Best seller
course iconJob OrientedUI/UX Design Bootcamp
  • 3 Months
Best seller
course iconEnterprise RecommendedJava Full Stack Developer Bootcamp
  • 6 Months
course iconCareer KickstarterFront-End Development Bootcamp
  • 490+ Hours
course iconCareer AcceleratorBackend Development Bootcamp (Node JS)
  • 4 Months
ReactNode JSAngularJavascriptPHP and MySQLcourse iconPurdue UniversityCloud Back-End Development Certificate Program
  • 8 Months
course iconPurdue UniversityFull Stack Development Certificate Program
  • 9 Months
course iconIIIT BangaloreExecutive Post Graduate Program in Software Development - Specialisation in FSD
  • 13 Months
Angular TrainingBasics of Spring Core and MVCFront-End Development BootcampReact JS TrainingSpring Boot and Spring CloudMongoDB Developer Coursecourse iconBlockchain Professional Certification
  • 40 Hours
course iconBlockchain Solutions Architect Certification
  • 32 Hours
course iconBlockchain Security Engineer Certification
  • 32 Hours
course iconBlockchain Quality Engineer Certification
  • 24 Hours
course iconBlockchain 101 Certification
  • 5+ Hours
NFT Essentials 101: A Beginner's GuideIntroduction to DeFiPython CertificationAdvanced Python CourseR Programming LanguageAdvanced R CourseJavaJava Deep DiveScalaAdvanced ScalaC# TrainingMicrosoft .Net Frameworkcourse iconSalary Hike GuaranteedSoftware Engineer Interview Prep
  • 3 Months
Data Structures and Algorithms with JavaScriptData Structures and Algorithms with Java: The Practical GuideLinux Essentials for Developers: The Complete MasterclassMaster Git and GitHubMaster Java Programming LanguageProgramming Essentials for BeginnersComplete Python Programming CourseSoftware Engineering Fundamentals and Lifecycle (SEFLC) CourseTest-Driven Development for Java ProgrammersTypeScript: Beginner to Advanced

Top 55+ Basic Docker Commands You Must Learn in 2025

By Lakshmi Sushmitha V

Updated on Jul 26, 2022 | 7 min read

Share:

DevOps is a natural evolution of software development. DevOps is not just a tool, a framework, or just automation. It is a combination of all these. DevOps aimed to align the Dev and Ops team with shared goals. A developer builds an application and sends it to the tester. But, the environments of development and testing systems are different; thus, the code does not work. There are two solutions to this: Docker and Virtual Machines.

Dockers have been used widely in many DevOps toolchains. Dockers platform provides numerous features that make it popular among developers. Some features include application isolation, portability, security management, Ease of software delivery, scalability, etc. Let's discuss the docker commands in more detail, along with examples! You can refer to the best Docker courses for training related to docker and docker commands. 

What is Docker?

Docker is a platform that enables the creation, deployment, and running of applications with the help of containers. A container is a unit of software that packages the code and all its dependencies together so that the application becomes runnable irrespective of the environment. 

The container isolates the application and its dependencies into a self-contained unit that can run anywhere. Container removes the need for physical hardware, allowing for more efficient use of computing resources. Containers provide operating-system-level virtualization. Additionally, using Docker commands, developers can easily manage these containers, enhancing their productivity and workflow efficiency.

Let's understand a few of the above commands along with their usage in detail. The following are the most used docker basic commands for beginners and experienced docker professionals. 

Here is the list of 50+ basic docker commands:

Top 15 Basic Docker Commands

1. docker –version

This command is used to get the current version of the docker

Syntax:

docker - -version [OPTIONS]

By default, this will render all version information in an easy-to-read layout. 

2. docker pull

Pull an image or a repository from a registry 

Syntax:

docker pull [OPTIONS] NAME[: TAG|@DIGEST] 

To download an image or set of images (i.e. A Repository) , Once can use docker pull command 

Example:

$ docker pull dockerimage

3. docker run

This command is used to create a container from an image 

Syntax:

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

The docker run command creates a writeable container layer over the specified image and then starts it using the specified command.

The docker run command can be used with many variations, One can refer to the following documentation docker run. 

4. docker ps

This command is used to list all the containers 

Syntax:

docker ps [OPTIONS]

The above command can be used with other options like - all or –a 

docker ps -all: Lists all containers 

Example:

$ docker ps
$ docker ps -a

5. docker exec

This command is used to run a command in a running container 

Syntax

docker exec [OPTIONS] CONTAINER COMMAND [ARG...]

Docker exec command runs a new command in a running container.

Refer to the following article for more detail regarding the usage of the docker exec command docker exec

6. docker stop

This command is used to stop one or more running containers. 

Syntax:

docker stop [OPTIONS] CONTAINER [CONTAINER...]

The main process inside the container will receive SIGTERM, and after a grace period, SIGKILL. The first signal can be changed with the STOPSIGNAL instruction in the container’s Dockerfile, or the --stop-signal option to docker run. 

Example:

$ docker stop my_container 

7. docker restart

This command is used to restart one or more containers. 

Syntax: docker restart [OPTIONS] CONTAINER [CONTAINER...] 

Example:

$ docker restart my_container 

8. docker kill

This command is used to kill one or more containers. 

Syntax: docker kill [OPTIONS] CONTAINER [CONTAINER...] 

Example:

$ docker kill my_container 

9. docker commit

This command is used to create a new image from the container image. 

Syntax: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]] 

Docker commit command allows users to take an existing running container and save its current state as an image 

There are certain steps to be followed before running the command

  • First , Pull the image from docker hub 
  • Deploy the container using the image id from first step 
  • Modify the container (Any changes ,if needed) 
  • Commit the changes 

Example:

$ docker commit c3f279d17e0a dev/testimage:version3. 

10. docker push

This docker command is used to push an image or repository to a registry. 

Syntax: docker push [OPTIONS] NAME[: TAG] 

Use docker image push to share your images to the Docker Hub registry or to a self-hosted one. 

Example:

$ docker image push registry-host:5000/myadmin/rhel-httpd:lates 

Apart from the above commands, we have other commands for which the detailing can be found in the following link Docker reference.

11. docker rm 

This command is used to remove one or more docker containers. We can use options such as -f i.e. force removal of running container which internally uses SIGKILL. Or -v  which removes any anonymous volumes associated with the container. 

Syntax: docker rm [OPTIONS] CONTAINER [CONTAINER...] 

Example:

docker rm container1 

Removing multiple containers:

docker rm container1 container2 container3 

Removing with -v and -f options:

docker rm -v container1 
docker rm -f  running_container  

12. docker rmi

This command is used to remove one or more docker images from the system. We can use some common options such as - f for force removal of an image or --no-prune for not deleting untagged parent images. 

Syntax:

docker rmi [OPTIONS] IMAGE  
  • Remove a single image:
docker rmi my_image:tag 
  • Remove multiple images:
docker rmi image1:tag image2:tag image3:tag 
  • Force remove an image:
docker rmi -f my_image:tag 
  • Removing image without deleting untagged images:
docker rmi --no-prune my_image:tag 

13. docker push 

This command is used to upload the docker image to a Docker registry such as  Docker Hub or a private registry. 

Syntax: docker push [OPTIONS] NAME[:TAG] 

Example:

Command: docker push myusername/myrepository:latest 

 14. docker login 

This command is used to log in to the Docker registry such as Docker Hub, a private registry, or any other third-party registry. We can use some common options such as -u for the username of the registry, -p for the password of the registry. 

Syntax: docker login [OPTIONS] [SERVER] 

Examples:  

  • Login to Docker Hub: docker login
Command: docker login 
  • Login with username and password:
Command: docker login -u myusername -p mypassword 

Note: In case we need to log in to other Docker registries:

Command: docker login myregistry.com 

15. docker start

This command is used to start one or more containers. We can use common options such as -a to attach stderr /stdout and forward signal. Also -i  option can be used as an interactive mode where the container STDIN can be attached. 

Syntax: docker start [OPTIONS] CONTAINER [CONTAINER...] 

Example:

  1. Starting Single Container:
Command: docker start  container1

One can become DevOps certified by referring to DevOps Certification courses

57 Essential Docker Commands List

Here are the top 57 essential/ basic docker commands with descriptions to learn and use.

Command Usage
docker attach Attach local standard input, output, and error streams to a running container
docker build Build an image from a Dockerfile
docker builder Manage builds
docker checkpoint Manage checkpoints
docker commit Create a new image from a container’s changes
docker config Manage Docker configs
docker container Manage containers
docker context Manage contexts
docker cp Copy files/folders between a container and the local filesystem
docker create Create a new container
docker diff Inspect changes to files or directories on a container’s filesystem
docker events Get real time events from the server
docker exec Run a command in a running container
docker export Export a container’s filesystem as a tar archive
docker history Show the history of an image
docker image Manage images
docker images List images
docker import Import the contents from a tarball to create a filesystem image
docker info Display system-wide information
docker inspect Return low-level information on Docker objects
docker kill Kill one or more running containers
docker load Load an image from a tar archive or STDIN
docker login Log in to a Docker registry
docker logout Log out from a Docker registry
docker logs Fetch the logs of a container
docker manifest Manage Docker image manifests and manifest lists
docker network Manage networks
docker node Manage Swarm nodes
docker pause Pause all processes within one or more containers
docker plugin Manage plugins
docker port List port mappings or a specific mapping for the container
docker ps List containers
docker pull Pull an image or a repository from a registry
docker push Push an image or a repository to a registry
docker rename Rename a container
docker restart Restart one or more containers
docker rm Remove one or more containers
docker rmi Remove one or more images
docker run Run a command in a new container
docker save Save one or more images to a tar archive (streamed to STDOUT by default)
docker search Search the Docker Hub for images
docker secret Manage Docker secrets
docker service Manage services
docker stack Manage Docker stacks
docker start Start one or more stopped containers
docker stats Display a live stream of container(s) resource usage statistics
docker stop Stop one or more running containers
docker swarm Manage Swarm
docker system Manage Docker
docker tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
docker top Display the running processes of a container
docker trust Manage trust on Docker images
docker unpause Unpause all processes within one or more containers
docker update Update configuration of one or more containers
docker version Show the Docker version information
docker volume Manage volumes
docker wait Block until one or more containers stop, then print their exit codes

Docker Use Cases

Let's understand a few of the docker use cases: 

Use case 1: Developers write their code locally and can share it using docker containers. 

Use case 2: Fixing the bugs and deploying them into the respective environments is as simple as pushing the image to the respective environment. 

Use case 3: Using docker one can push their application to the test environment and execute automated and manual tests 

Use case 4: One can make their deployment responsive and scalable by using docker since docker can handle dynamic workloads feasibility. 

Let us take an example of an application, 

When a company wants to develop a web application, it needs an environment where they have a Tomcat server installed. Once the tester set up a tomcat environment and test the application, it is deployed into a production environment. Once again the tomcat has to be setup in a production environment to host the java web application There are some issues with this approach: 

  • Loss of time and effort. 
  • Developer and tester might use a different tomcat versions.

Now, let's see how the Docker container can be used to prevent this loss.

In order to overcome the issues, docker will be used by a developer to create a docker image using a base image which is already existing in Docker hub. Docker hub has some base images available for free. Now this image can be used by the developer, tester, and the system admin to deploy a Tomcat environment using Docker Commands. In this way, Docker container solves the problem.

Docker Architecture

Docker architecture generally consists of a Docker Engine which is a client-server application with three major components: 

  1. Generally, docker follows a client-server architecture 
  2. The client communicates with the daemon, which generally takes up the task of building, running, and shipping the docker containers. 
  3. The client and daemon communicate using REST API calls. These calls act as an interface between the client and daemon 
  4. A command-line interface, Docker CLI runs docker commands. Some basic docker commands with examples are listed in the next section. 
  5. Registry stores the docker images

Conclusion

DevOps (development + operations) is an evolution born between developers and system administrators. One of the main tasks of DevOps is the automation and centralization of software development and deployment. One of the most popular tools that helps solve this task is Docker. To get a better understanding of Docker commands and more, enroll in Docker Kubernetes training

Three main features of Docker products are the most distinguishing: 

  • Quick deployment in a variety of environments 
  • Greatly facilitated testing 
  • Possibility of using Docker as a development environment.

Learning the top Docker commands is essential for any DevOps professional looking to streamline container management and deployment processes. As you continue to explore and learn more about Docker, keeping these commands at your fingertips will prove invaluable in your journey toward DevOps operational excellence.

Frequently Asked Questions (FAQs)

1. What do you mean by Docker command line?

2. How many commands are there in Docker?

3. What is an image in Docker?

4. How can I run a docker command?

Lakshmi Sushmitha V

2 articles published

Get Free Consultation

+91

By submitting, I accept the T&C and
Privacy Policy

Suggested Blogs