Explore Courses
Liverpool Business SchoolLiverpool Business SchoolMBA by Liverpool Business School
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA (Master of Business Administration)
  • 15 Months
Popular
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Business Administration (MBA)
  • 12 Months
New
Birla Institute of Management Technology Birla Institute of Management Technology Post Graduate Diploma in Management (BIMTECH)
  • 24 Months
Liverpool John Moores UniversityLiverpool John Moores UniversityMS in Data Science
  • 18 Months
Popular
IIIT BangaloreIIIT BangalorePost Graduate Programme in Data Science & AI (Executive)
  • 12 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
upGradupGradData Science Bootcamp with AI
  • 6 Months
New
University of MarylandIIIT BangalorePost Graduate Certificate in Data Science & AI (Executive)
  • 8-8.5 Months
upGradupGradData Science Bootcamp with AI
  • 6 months
Popular
upGrad KnowledgeHutupGrad KnowledgeHutData Engineer Bootcamp
  • Self-Paced
upGradupGradCertificate Course in Business Analytics & Consulting in association with PwC India
  • 06 Months
OP Jindal Global UniversityOP Jindal Global UniversityMaster of Design in User Experience Design
  • 12 Months
Popular
WoolfWoolfMaster of Science in Computer Science
  • 18 Months
New
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Rushford, GenevaRushford Business SchoolDBA Doctorate in Technology (Computer Science)
  • 36 Months
IIIT BangaloreIIIT BangaloreCloud Computing and DevOps Program (Executive)
  • 8 Months
New
upGrad KnowledgeHutupGrad KnowledgeHutAWS Solutions Architect Certification
  • 32 Hours
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Popular
upGradupGradUI/UX Bootcamp
  • 3 Months
upGradupGradCloud Computing Bootcamp
  • 7.5 Months
Golden Gate University Golden Gate University Doctor of Business Administration in Digital Leadership
  • 36 Months
New
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Golden Gate University Golden Gate University Doctor of Business Administration (DBA)
  • 36 Months
Bestseller
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDoctorate of Business Administration (DBA)
  • 36 Months
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (DBA)
  • 36 Months
KnowledgeHut upGradKnowledgeHut upGradSAFe® 6.0 Certified ScrumMaster (SSM) Training
  • Self-Paced
KnowledgeHut upGradKnowledgeHut upGradPMP® certification
  • Self-Paced
IIM KozhikodeIIM KozhikodeProfessional Certification in HR Management and Analytics
  • 6 Months
Bestseller
Duke CEDuke CEPost Graduate Certificate in Product Management
  • 4-8 Months
Bestseller
upGrad KnowledgeHutupGrad KnowledgeHutLeading SAFe® 6.0 Certification
  • 16 Hours
Popular
upGrad KnowledgeHutupGrad KnowledgeHutCertified ScrumMaster®(CSM) Training
  • 16 Hours
Bestseller
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 4 Months
upGrad KnowledgeHutupGrad KnowledgeHutSAFe® 6.0 POPM Certification
  • 16 Hours
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Science in Artificial Intelligence and Data Science
  • 12 Months
Bestseller
Liverpool John Moores University Liverpool John Moores University MS in Machine Learning & AI
  • 18 Months
Popular
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
IIIT BangaloreIIIT BangaloreExecutive Post Graduate Programme in Machine Learning & AI
  • 13 Months
Bestseller
IIITBIIITBExecutive Program in Generative AI for Leaders
  • 4 Months
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
IIIT BangaloreIIIT BangalorePost Graduate Certificate in Machine Learning & Deep Learning (Executive)
  • 8 Months
Bestseller
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Liverpool Business SchoolLiverpool Business SchoolMBA with Marketing Concentration
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA with Marketing Concentration
  • 15 Months
Popular
MICAMICAAdvanced Certificate in Digital Marketing and Communication
  • 6 Months
Bestseller
MICAMICAAdvanced Certificate in Brand Communication Management
  • 5 Months
Popular
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Corporate & Financial Law
  • 12 Months
Bestseller
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in AI and Emerging Technologies (Blended Learning Program)
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Intellectual Property & Technology Law
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Dispute Resolution
  • 12 Months
upGradupGradContract Law Certificate Program
  • Self paced
New
ESGCI, ParisESGCI, ParisDoctorate of Business Administration (DBA) from ESGCI, Paris
  • 36 Months
Golden Gate University Golden Gate University Doctor of Business Administration From Golden Gate University, San Francisco
  • 36 Months
Rushford Business SchoolRushford Business SchoolDoctor of Business Administration from Rushford Business School, Switzerland)
  • 36 Months
Edgewood CollegeEdgewood CollegeDoctorate of Business Administration from Edgewood College
  • 24 Months
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with Concentration in Generative AI
  • 36 Months
Golden Gate University Golden Gate University DBA in Digital Leadership from Golden Gate University, San Francisco
  • 36 Months
Liverpool Business SchoolLiverpool Business SchoolMBA by Liverpool Business School
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA (Master of Business Administration)
  • 15 Months
Popular
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Business Administration (MBA)
  • 12 Months
New
Deakin Business School and Institute of Management Technology, GhaziabadDeakin Business School and IMT, GhaziabadMBA (Master of Business Administration)
  • 12 Months
Liverpool John Moores UniversityLiverpool John Moores UniversityMS in Data Science
  • 18 Months
Bestseller
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Science in Artificial Intelligence and Data Science
  • 12 Months
Bestseller
IIIT BangaloreIIIT BangalorePost Graduate Programme in Data Science (Executive)
  • 12 Months
Bestseller
O.P.Jindal Global UniversityO.P.Jindal Global UniversityO.P.Jindal Global University
  • 12 Months
WoolfWoolfMaster of Science in Computer Science
  • 18 Months
New
Liverpool John Moores University Liverpool John Moores University MS in Machine Learning & AI
  • 18 Months
Popular
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (AI/ML)
  • 36 Months
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDBA Specialisation in AI & ML
  • 36 Months
Golden Gate University Golden Gate University Doctor of Business Administration (DBA)
  • 36 Months
Bestseller
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDoctorate of Business Administration (DBA)
  • 36 Months
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (DBA)
  • 36 Months
Liverpool Business SchoolLiverpool Business SchoolMBA with Marketing Concentration
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA with Marketing Concentration
  • 15 Months
Popular
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Corporate & Financial Law
  • 12 Months
Bestseller
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Intellectual Property & Technology Law
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Dispute Resolution
  • 12 Months
IIITBIIITBExecutive Program in Generative AI for Leaders
  • 4 Months
New
IIIT BangaloreIIIT BangaloreExecutive Post Graduate Programme in Machine Learning & AI
  • 13 Months
Bestseller
upGradupGradData Science Bootcamp with AI
  • 6 Months
New
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
KnowledgeHut upGradKnowledgeHut upGradSAFe® 6.0 Certified ScrumMaster (SSM) Training
  • Self-Paced
upGrad KnowledgeHutupGrad KnowledgeHutCertified ScrumMaster®(CSM) Training
  • 16 Hours
upGrad KnowledgeHutupGrad KnowledgeHutLeading SAFe® 6.0 Certification
  • 16 Hours
KnowledgeHut upGradKnowledgeHut upGradPMP® certification
  • Self-Paced
upGrad KnowledgeHutupGrad KnowledgeHutAWS Solutions Architect Certification
  • 32 Hours
upGrad KnowledgeHutupGrad KnowledgeHutAzure Administrator Certification (AZ-104)
  • 24 Hours
KnowledgeHut upGradKnowledgeHut upGradAWS Cloud Practioner Essentials Certification
  • 1 Week
KnowledgeHut upGradKnowledgeHut upGradAzure Data Engineering Training (DP-203)
  • 1 Week
MICAMICAAdvanced Certificate in Digital Marketing and Communication
  • 6 Months
Bestseller
MICAMICAAdvanced Certificate in Brand Communication Management
  • 5 Months
Popular
IIM KozhikodeIIM KozhikodeProfessional Certification in HR Management and Analytics
  • 6 Months
Bestseller
Duke CEDuke CEPost Graduate Certificate in Product Management
  • 4-8 Months
Bestseller
Loyola Institute of Business Administration (LIBA)Loyola Institute of Business Administration (LIBA)Executive PG Programme in Human Resource Management
  • 11 Months
Popular
Goa Institute of ManagementGoa Institute of ManagementExecutive PG Program in Healthcare Management
  • 11 Months
IMT GhaziabadIMT GhaziabadAdvanced General Management Program
  • 11 Months
Golden Gate UniversityGolden Gate UniversityProfessional Certificate in Global Business Management
  • 6-8 Months
upGradupGradContract Law Certificate Program
  • Self paced
New
IU, GermanyIU, GermanyMaster of Business Administration (90 ECTS)
  • 18 Months
Bestseller
IU, GermanyIU, GermanyMaster in International Management (120 ECTS)
  • 24 Months
Popular
IU, GermanyIU, GermanyB.Sc. Computer Science (180 ECTS)
  • 36 Months
Clark UniversityClark UniversityMaster of Business Administration
  • 23 Months
New
Golden Gate UniversityGolden Gate UniversityMaster of Business Administration
  • 20 Months
Clark University, USClark University, USMS in Project Management
  • 20 Months
New
Edgewood CollegeEdgewood CollegeMaster of Business Administration
  • 23 Months
The American Business SchoolThe American Business SchoolMBA with specialization
  • 23 Months
New
Aivancity ParisAivancity ParisMSc Artificial Intelligence Engineering
  • 24 Months
Aivancity ParisAivancity ParisMSc Data Engineering
  • 24 Months
The American Business SchoolThe American Business SchoolMBA with specialization
  • 23 Months
New
Aivancity ParisAivancity ParisMSc Artificial Intelligence Engineering
  • 24 Months
Aivancity ParisAivancity ParisMSc Data Engineering
  • 24 Months
upGradupGradData Science Bootcamp with AI
  • 6 Months
Popular
upGrad KnowledgeHutupGrad KnowledgeHutData Engineer Bootcamp
  • Self-Paced
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Bestseller
KnowledgeHut upGradKnowledgeHut upGradBackend Development Bootcamp
  • Self-Paced
upGradupGradUI/UX Bootcamp
  • 3 Months
upGradupGradCloud Computing Bootcamp
  • 7.5 Months
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 5 Months
upGrad KnowledgeHutupGrad KnowledgeHutSAFe® 6.0 POPM Certification
  • 16 Hours
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
upGradupGradData Science Bootcamp with AI
  • 6 Months
Popular
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Bestseller
upGradupGradUI/UX Bootcamp
  • 3 Months
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 4 Months
upGradupGradCertificate Course in Business Analytics & Consulting in association with PwC India
  • 06 Months
upGradupGradDigital Marketing Accelerator Program
  • 05 Months

Top 20 Essential Docker Commands You Should Know in 2024

Updated on 15 June, 2023

13.99K+ views
7 min read

Introduction

Docker commands are crucial containerisation tools that allow programs to operate smoothly across numerous environments. With these commands, programmers can easily construct, deploy and manage containers. They also enable developers to create container images, orchestrate containerised applications, and instantiate containers.

Developers containerise their dependencies and programs in self-contained units with Docker commands because it guarantees reliable and consistent deployment. Docker commands make it easier to manage software applications, allowing for shorter development cycles, more scalability, and greater portability across several computer environments

This blog serves as a guide explaining in detail what docker commands are and their purpose. It also provides a holistic Docker commands list with examples.

What Is Docker and Why Is It Important?

Docker is an open-source platform that uses containerisation to simplify application creation, packaging, and deployments. It enables developers to package their applications and dependencies into isolated and portable units known as containers.

A container is a software element that combines code and its dependencies, allowing the application to run irrespective of the underlying system. It encapsulates the application and its dependencies into a self-contained unit, ensuring compatibility across different environments.

Docker is highly beneficial because it ensures consistency throughout environments and enables programs to operate systematically on any machine. It has a standardised environment that encourages cooperation among development teams and helps maintain consistent outcomes. Through containerisation, it improves scalability by optimising resource use. Docker also simplifies deployment, making applications run faster and improving operational efficiency.

Overall, Docker transforms application development by offering an adaptable, effective, and portable approach to developing and distributing applications.

Setting Up Docker Environment

Establishing a Docker environment is significant due to its ability to create isolated containers, ensuring consistent application deployment. It simplifies dependency management, optimises scalability and resource utilisation, fosters collaboration, and streamlines the development and deployment process, resulting in improved productivity and reliable application deployment.

Follow the steps below to establish a Docker environment:

  1. Install Docker: Install Docker from the official Docker website, tailored to your specific operating system.
  2. Confirm Installation: Validate the Docker installation by executing the “docker version” command in a terminal or command prompt.
  3. Obtain Docker Images: Retrieve essential Docker images from Docker Hub using the “docker pull” command and the corresponding image name.
  4. Formulate a Dockerfile: Craft a text file called “Dockerfile”, encompassing the necessary directives for constructing the desired container image.
  5. Construct the Docker Image: Execute the “docker build” command, specifying the directory housing the Dockerfile to fabricate the image.
  6. Launch Containers: Commence container instances based on the built images using the “docker run” command with suitable options.
  7. Manage Containers: Effectively handle containers using various Docker commands such as “docker ps” to enlist running containers and “docker stop” to halt their execution.

Basic Docker Commands

Basic Docker commands are essential for managing containers and images. They enable tasks such as running containers, listing running containers, managing images, stopping containers, removing containers, and interacting with containers. These commands facilitate container deployment, monitoring, and maintenance.

Here is a docker commands list of the basic yet most widely used ones that help manage containers, images, and the overall Docker environment:

Docker run

This command initiates creating and activating a fresh container using a Docker image. It provides options to configure aspects like port mappings, environment variables, and volume mounts.

For instance, the Docker run -d option is used to run a container in detached mode. When the Docker -d command is selected, the container operates in the background, enabling you to keep using the command prompt or the terminal without being connected to the container’s console.

Docker ps

The “docker ps” command is used to present data regarding the active containers on a Docker host. It offers insights such as container ID, utilised image, container status, port mapping, and resource usage. This command aids in monitoring running containers and acquiring vital information for Docker environment management.

Check out our free technology courses to upskill yourself

Docker images

This command displays a collection of Docker images stored locally. It showcases information like image ID, repository, and tag.

Docker stop all containers

This command is employed to halt all active containers simultaneously. By combining commands, it retrieves the IDs of running containers and then passes them to the “docker stop” command. Consequently, all currently running containers on the Docker host are stopped, offering a convenient means to halt multiple containers simultaneously.

Docker rm

This command deletes one or more stopped containers from the system. It aids in removing unnecessary containers and performing clean-up tasks.

Docker rmi

This command erases one or more Docker images from the local environment. This action reclaims storage space by eliminating specified images.

Docker build

This command constructs a new Docker image based on instructions provided in a Dockerfile. It may involve installing dependencies, configuring the environment, and copying application code.

Docker push

This command uploads a Docker image to a registry, like Docker Hub or a private registry. This facilitates sharing the image with others or deploying it in different environments

Learn Software Development Courses online from the World’s top Universities. Earn Executive PG Programs, Advanced Certificate Programs or Masters Programs to fast-track your career.

Docker pull

This command retrieves a Docker image from a registry to the local system. This enables obtaining a remotely stored image for running containers on the local machine.

Are you looking to gain a foothold in DevOps? Check out the online DevOps Bootcamp – Advanced Certificate Program for professional guidance on DevOps and its fundamentals, including Docker.

Advanced Docker Commands

Advanced Docker commands serve the purpose of handling intricate container management operations. These include tasks like defining multi-container applications, managing networks and data storage, monitoring container performance, examining object details, and orchestrating container clusters. Consider signing up for the Master of Science in Computer Science from LJMU to learn more about advanced Docker commands.

Some of the most used advanced Docker commands have been listed below for your reference:

Docker-compose

This Docker tool is used for defining and controlling multi-container applications. It employs a YAML file to specify the necessary services, networks, and volumes for the application, simplifying the deployment process.

Docker network

This advanced command manages networks that enable communication between containers. It allows containers to interact with each other or external systems by connecting them to specific networks.

Docker volume

This command handles persistent data storage for containers. It provides a means to store and share data between containers or between containers and the host system.

Docker logs

This command retrieves container-generated logs, displaying output and error messages. This aids in troubleshooting and debugging by providing insights into a running container’s activities.

Docker exec

This command executes commands within a running container. It facilitates interactive or detached execution of commands, useful for tasks like debugging or configuration changes.

Docker stats

This command presents real-time resource usage statistics for running containers. It offers information on CPU, memory, and network utilisation, assisting in monitoring and optimising container performance.

Docker inspect

This command provides detailed information about Docker objects, including containers, images, networks, and volumes. It offers an extensive view of configuration, network settings, and other object-specific details.

Docker history

This command reveals an image’s construction history, including layers and commands used. It aids in understanding an image’s size, dependencies, and modifications made throughout its development.

Docker commit

This command creates a new image from changes made to a running container, preserving its current state. This enables the storage and sharing of modified containers as new images.

Docker save/load

This command archives and restores Docker images to/from a tarball file. It facilitates exporting and importing Docker images and making them transferable across different Docker environments.

Docker swarm

This command facilitates the creation and management of a cluster of Docker nodes. It supports container orchestration and scalability, allowing for the deployment and administration of containers across multiple hosts in a swarm cluster.

Conclusion

Docker commands are critical components of the containerisation ecosystem and allow developers to build, supervise, and deploy applications effortlessly. They are indispensable for reaping the full benefits of containerisation, allowing developers to bundle and distribute apps across several environments effectively. With a wide range of Docker tools, developers can create and manage containers and achieve consistency, expansion, and portability by facilitating smooth deployment and cooperation.

You can explore the Executive PG Programme in Full Stack Development from IIITB presented by upGrad for a comprehensive understanding of Docker tools. This program, carefully crafted by professionals in the field, offers an opportunity to enhance your skills and obtain valuable certifications to propel your professional journey forward. Sign up today.

Frequently Asked Questions (FAQs)

1. Which Docker commands are commonly used by developers?

Developers frequently use a range of Docker commands, such as Docker run, Docker build, Docker stop container, Docker ps, Docker exec, and Docker push. These commands hold significant popularity within the Docker ecosystem.

2. How can one view the Docker container logs?

You must use the Docker logs command to view specific Docker container logs and enter the container ID or name.

3. Can a Docker container be renamed?

Docker does not offer a command to rename a container. Nonetheless, a viable approach is to generate a fresh container using the preferred name and transfer the data from the existing container to the new one before eliminating the original container.

RELATED PROGRAMS