Day 20 - Docker Cheat Sheet

Day 20 - Docker Cheat Sheet

Docker is a powerful platform that enables developers to create, deploy, and run applications in containers. Whether you're a beginner or looking to enhance your Docker skills, this cheat sheet will guide you through Docker installation, volume management, image handling, and container operations.

Image Management:

  1. Pull an Image:docker pull <image_name>This command fetches a Docker image from a registry, such as Docker Hub.
  2. List Downloaded Images:docker imagesDisplays a list of locally stored Docker images.
  3. Remove an Image:docker rmi <image_name or image_id>Deletes a Docker image from the local machine.



Docker Volumes:

  1. Create a Docker Volume:docker volume create <volume_name>Creates a Docker volume.
  2. Run a Container with a Volume:docker run -v <volume_name>:<container_directory> <image_name>Attaches a volume to a container, preserving data in the container's directory on the volume.
  3. Inspect a Volume:docker volume inspect <volume_name>Provides detailed information about a Docker volume.



Container Lifecycle:

  1. Run a Container:docker run <options> <image_name>Starts a new container instance from a Docker image.
  2. List Running Containers:bashCopy codedocker psShows a list of currently running containers.
  3. List All Containers:docker ps -aDisplays all containers, including stopped ones.
  4. Stop a Running Container:docker stop <container_id or container_name>Halts a running container.
  5. Remove a Container:docker rm <container_id or container_name>Deletes a stopped container.



Container Interaction:

  1. Execute Commands Inside a Container:docker exec -it <container_id or container_name> <command>Allows you to run commands inside a running container.
  2. Attach to a Running Container:docker attach <container_id or container_name>Attaches your terminal to a running container.



Docker Compose Commands:

  1. Compose Up:docker-compose upBuilds and starts containers based on the docker-compose.yml file.
  2. Compose Down:docker-compose downStops and removes containers, networks, and volumes defined in the docker-compose.yml file.
  3. Compose Logs:docker-compose logsDisplays log output from services defined in docker-compose.yml.
  4. Scale Services:docker-compose scale <service_name>=<num_of_instances>Scales the number of containers for a specific service.



Docker Networking:

  1. List Networks:docker network lsShows a list of Docker networks.
  2. Inspect a Network:docker network inspect <network_name>Provides detailed information about a Docker network.
  3. Create a Network:docker network create <network_name>Creates a new Docker network.



Miscellaneous:

  1. Docker Version:docker versionDisplays the Docker version information.
  2. Docker Info:docker infoShows system-wide information about Docker.
  3. Clean Up Docker Resources:docker system prune -aRemoves stopped containers, unused networks, and dangling images.


Now that you have this comprehensive cheat sheet, you'll be well-equipped to navigate the Docker ecosystem efficiently. Feel free to share this resource with the DevOps community, and remember, continuous learning is the key to mastering Docker! Happy containerizing.

要查看或添加评论,请登录

Muhammad Shaheryar的更多文章

  • Day 30 - Terraform

    Day 30 - Terraform

    Introduction Terraform is a powerful open-source tool that falls under the category of Infrastructure as Code (IaC). It…

  • Day 29 - Jenkins Important interview Questions

    Day 29 - Jenkins Important interview Questions

    Mastering Jenkins for Docker-Centric CI/CD: A Comprehensive Interview Guide In the ever-evolving landscape of DevOps…

  • Day 28 - Jenkins Agents

    Day 28 - Jenkins Agents

    Introduction Jenkins, an open-source automation server, plays a crucial role in orchestrating workflows through…

  • Day 27 - Jenkins Declarative Pipeline with Docker

    Day 27 - Jenkins Declarative Pipeline with Docker

    Welcome back to our Jenkins journey! We've already mastered the basics of Declarative Pipelines in Jenkins. Now, let's…

  • Day 26 - Jenkins Declarative Pipeline

    Day 26 - Jenkins Declarative Pipeline

    Introduction In the realm of DevOps and Continuous Integration/Continuous Deployment (CICD), Jenkins plays a pivotal…

    3 条评论
  • Day 25 - Complete Jenkins CI/CD Project - Continued with Documentation

    Day 25 - Complete Jenkins CI/CD Project - Continued with Documentation

    Continuous Integration (CI) and Continuous Deployment (CD) are crucial components of modern software development…

  • Day 24 - Complete Jenkins CI/CD Project

    Day 24 - Complete Jenkins CI/CD Project

    Introduction Welcome to this comprehensive guide on setting up a Jenkins CI/CD pipeline for deploying a Node.js To-Do…

  • Day 23 Task: Jenkins Freestyle Project for DevOps Engineers.

    Day 23 Task: Jenkins Freestyle Project for DevOps Engineers.

    Introduction In the dynamic realm of software development, Continuous Integration (CI) and Continuous Delivery (CD)…

  • Day 22 - Getting Started with Jenkins

    Day 22 - Getting Started with Jenkins

    Understanding Jenkins: At its core, Jenkins is an open-source automation server, a DevOps tool crafted in the Java…

  • Day 21 - Docker Important Interview Questions

    Day 21 - Docker Important Interview Questions

    Introduction In the dynamic landscape of DevOps engineering, Docker has emerged as a cornerstone technology. Docker…

社区洞察

其他会员也浏览了