Deployment·

Docker Cheat Sheet

A quick reference table of Docker containers, images, networks, volumes, and more.

Sure! Here’s a Docker cheat sheet in English covering common Docker commands and operations:

Docker Cheat Sheet

Basic Commands

# Check Docker version
docker --version

# Display Docker system information
docker info

# Display help
docker --help

Container Management

# Pull an image
docker pull <image>

# List local images
docker images

# Remove an image
docker rmi <image>

# Create and start a container
docker run -d --name <container_name> <image>

# Run an interactive container
docker run -it <image> /bin/bash

# Start a stopped container
docker start <container_name>

# Stop a running container
docker stop <container_name>

# Restart a container
docker restart <container_name>

# Remove a container
docker rm <container_name>

# Display running containers
docker ps

# Display all containers (including stopped ones)
docker ps -a

# Display container logs
docker logs <container_name>

Image Management

# Build an image
docker build -t <image_name> .

# List local images
docker images

# Remove an image
docker rmi <image_name>

# View image history
docker history <image_name>

Network Management

# List Docker networks
docker network ls

# Create a custom network
docker network create <network_name>

# Connect a container to a network
docker network connect <network_name> <container_name>

# Disconnect a container from a network
docker network disconnect <network_name> <container_name>

# Remove a network
docker network rm <network_name>

Volume Management

# Create a volume
docker volume create <volume_name>

# List volumes
docker volume ls

# View volume details
docker volume inspect <volume_name>

# Remove a volume
docker volume rm <volume_name>

Docker Compose

# docker-compose.yml example
version: '3'
services:
  web:
    image: nginx
    ports:
      - "80:80"
  db:
    image: mysql
    environment:
      MYSQL_ROOT_PASSWORD: example

# Start services
docker-compose up

# Start services in detached mode
docker-compose up -d

# Stop services
docker-compose down

# View service status
docker-compose ps

# Restart services
docker-compose restart

I hope this cheat sheet is helpful! If you need anything more specific or have other questions, feel free to ask.