Skip to main content

Command Palette

Search for a command to run...

Day 20 Task: Docker Cheat Sheet

Published
β€’1 min readβ€’View as Markdown

🐳 Docker Cheat Sheet: Streamlining Container Operations! πŸš€

Greetings, DevOps enthusiasts! Excited to share a Docker cheat sheet to navigate the container seas efficiently. Let's dive in! πŸ› οΈ

Docker Commands:

  1. Build an Image:

     docker build -t your-image-name:tag .
    

    Builds a Docker image from the current directory.

  2. Run a Detached Container:

     docker run -d -p host-port:container-port your-image-name:tag
    

    Spins up a detached container, mapping ports for accessibility.

  3. List Running Containers:

     docker ps
    

    Displays active containers and their vital details.

  4. Inspect Container Details:

     docker inspect container-id
    

    Fetches in-depth information about a specific container.

  5. View Container Logs:

     docker logs container-id
    

    Retrieves and displays logs for a specific container.

  6. Stop and Remove Containers:

     docker stop container-id
     docker rm container-id
    

    Gracefully stops and removes a running container.

Bonus Tips:

  • Run Without Sudo:

      sudo usermod -aG docker $USER
    

    Enables running Docker commands without sudo.

  • Remove Docker Images:

      docker rmi image-id
    

    Deletes a Docker image.

Conclusion:

Docker is a powerhouse for container orchestration, and mastering these commands empowers efficient operations. Keep this cheat sheet handy for smooth sailing in the containerized world!

More from this blog

Introduction Of DevOps

108 posts