Docker Cheat Sheet: #Day20 of 90Daysof DevOps

ยท

2 min read

Quick reference guide for Docker commands along with examples to help you get started.

  • Docker Build images

  • Docker Run containers

  • Docker Manage containers

  1. docker version: Check the Docker version.
    Example: docker version

  2. docker info: Display system-wide information about Docker.
    Example: docker info

  3. docker pull: Pull an image from a repository.
    Example: docker pull ubuntu:latest

  4. docker run: Create and start a container from an image.

    Example: docker run -it --rm ubuntu:latest

  5. docker ps: List running containers.
    Example: docker ps

  6. docker ps -a: List all containers (including stopped ones).
    Example: docker ps -a

  7. docker exec: Run a command in a running container.
    Example: docker exec -it container_name /bin/bash

  8. docker stop: Stop a running container.
    Example: docker stop container_name

  9. docker start: Start a stopped container.
    Example: docker start container_name

  10. docker restart: Restart a running container.

    Example: docker restart container_name

  11. docker rm: Remove a stopped container.
    Example: docker rm container_name

  12. docker rmi: Remove an image.
    Example: docker rmi ubuntu:latest

  13. docker build: Build an image from a Dockerfile.
    Example: docker build -t my_image_name .

  14. docker images: List available images.
    Example: docker images

  15. docker-compose up: Start services defined in a Compose file.

    Example: docker-compose up -d

  16. docker-compose down: Stop and remove containers, networks, and volumes defined in a Compose file.
    Example: docker-compose down

  17. docker network creates: Create a network.
    Example:docker network create my_network

  18. docker volume creates: Create a volume.
    Example: docker volume create my_volume

  19. docker logs: View logs from a container.
    Example: docker logs container_name

  20. docker inspect: Display detailed information about a container or image. Example: docker inspect container_name

You can replace the command options, image names, and container names with your own choices.

You can also refer below images for your reference:

Thank you for reading. Happy Learning ๐Ÿ˜Š!!!

ย