Skip to main content

Command Palette

Search for a command to run...

Day 20 : ๐Ÿš€ Docker Cheat Sheet: Essential Commands for Images, Containers, and Docker Hub ๐ŸŒŸ

Updated
โ€ข2 min read
Day 20 : ๐Ÿš€ Docker Cheat Sheet: Essential Commands for Images, Containers, and Docker Hub ๐ŸŒŸ
A

"I'm a 3rd-year Computer Engineering student at Marwadi University with skills in C++, web development (MERN stack), and DevOps tools like Kubernetes. I contribute to open-source projects and share tech knowledge on GitHub and LinkedIn. I'm learning cloud technologies and app deployment. As an Internshala Student Partner, I help others find jobs and courses." now currently focusing on #90DaysOfDevops

Docker Cheat Sheet

Docker is a powerful platform for developing, shipping, and running applications inside containers. This cheat sheet covers essential Docker commands for managing images, containers, general operations, and Docker Hub interactions.

Images Commands

  • List Images

      docker images
    

    Lists all images on your local machine.

  • Pull an Image

      docker pull <image_name>
    

    Downloads an image from Docker Hub.

  • Remove an Image

      docker rmi <image_name>
    

    Deletes an image from your local machine.

  • Build an Image

      docker build -t <image_name> <path_to_dockerfile> or .
    

    Builds an image from a Dockerfile.

  • Tag an Image

      docker tag <image_id> <new_image_name>
    

    Tags an image with a new name.

Containers Commands

  • List Containers

      docker ps
    

    Lists all running containers.

  • List All Containers

      docker ps -a
    

    Lists all containers, including stopped ones.

  • Run a Container

      docker run -d --name <container_name> <image_name>
    

    Runs a container in detached mode.

  • Stop a Container

      docker stop <container_name>
    

    Stops a running container.

  • Remove a Container

      docker rm <container_name>
    

    Deletes a stopped container.

  • Start a Container

      docker start <container_name>
    

    Starts a stopped container.

  • Restart a Container

      docker restart <container_name>
    

    Restarts a running container.

  • Attach to a Running Container

      docker attach <container_name>
    

    Attaches your terminal to a running container.

General Commands

  • Docker Version

      docker --version
    

    Displays the Docker version installed on your machine.

  • Docker Info

      docker info
    

    Displays system-wide information about Docker.

  • Login to Docker Hub

      docker login
    

    Logs you into Docker Hub.

  • Logout from Docker Hub

      docker logout
    

    Logs you out of Docker Hub.

  • Docker Help

      docker --help
    

    Displays help information for Docker commands.

Docker Hub Commands

  • Push an Image to Docker Hub

      docker push <image_name>
    

    Uploads an image to Docker Hub.

  • Pull an Image from Docker Hub

      docker pull <image_name>
    

    Downloads an image from Docker Hub.

  • Search for an Image on Docker Hub

      docker search <image_name>
    

    Searches for an image on Docker Hub.

Conclusion

This cheat sheet provides a quick reference to the most commonly used Docker commands. Whether you're managing images, containers, or interacting with Docker Hub, these commands will help streamline your workflow. Happy Dockering!

90DaysOfDevops

Part 27 of 49

So In This Series I am following 90 DaysOfDevops challenge , what i will learn in my devops journey i will share with you with my blogs ,You will get blog on tools which used by devops engineer , example :- Linux,ansible,terraform,docker,etc

Up next

Day 19: Docker for DevOps Engineers ๐Ÿš€

So far, you've learned how to create a docker-compose.yml file and push it to the repository. Let's move forward and explore more Docker Compose concepts. Today, let's study Docker Volume and Docker Network! ๐Ÿ˜ƒ Docker Volume Docker allows you to crea...

More from this blog

A

Anand Raval

118 posts

Hello I am Anand Raval , i contributed my work in robotics(arduino uno) , fronted web devloper,competitive programming, now currently focusing on #90DaysOfDevops