Skip to content

Docker Installation & Config Guide

Docker is an open-source application container engine that allows developers to package their applications and dependencies into a portable container, which can then be published to any popular Linux or Windows machine.

Containerization

Docker Installation

Linux (Official Install Script)

Suitable for major distributions like Ubuntu, Debian, CentOS. The official script automatically detects the system and installs the latest stable version.

bash
curl -fsSL https://get.docker.com | bash

After installation, start Docker and enable it to run on boot:

bash
sudo systemctl start docker
sudo systemctl enable docker

Windows

  1. Ensure your system is Windows 10/11 Pro/Enterprise/Education (supports Hyper-V), or check if WSL 2 is installed.
  2. Go to Docker Desktop for Windows to download the installer.
  3. Run the installer and follow the prompts to complete the installation.
  4. Restart your computer after installation.

macOS

  1. Go to Docker Desktop for Mac to download the .dmg file.
  2. Choose Mac with Intel chip or Mac with Apple chip depending on your chip type.
  3. Drag the Docker icon to the Applications folder.

Command Cheat Sheet

CommandDescription
Image Management
docker pull <image>Pull an image
docker imagesList local images
docker rmi <id>Remove an image
Container Operations
docker run -d -p 80:80 <image>Run in background and map ports
docker psList running containers
docker ps -aList all containers (including stopped ones)
docker stop <id>Stop a container
docker rm <id>Remove a container
docker logs -f <id>View real-time container logs
docker exec -it <id> shEnter container terminal

Docker Compose (V2)

Newer versions of Docker Desktop and Linux packages include the docker compose command (note the space, no longer docker-compose).

Common Commands:

bash
# Start all services in the background
docker compose up -d

# Stop and remove containers
docker compose down

# View service logs
docker compose logs -f

# Update images and restart
docker compose pull && docker compose up -d

⚠️ FAQ

1. Permission Issues (Linux)

Symptom: permission denied when running docker commands. Solution: Add current user to the docker group (run without sudo).

bash
sudo usermod -aG docker $USER
# Log out and log back in, or run this command for immediate effect:
newgrp docker

2. Slow / Timeout Image Pulling

Due to network reasons, connecting directly to Docker Hub may fail. It is recommended to configure an image accelerator/mirror.

Edit or create /etc/docker/daemon.json:

json
{
  "registry-mirrors": [
    "https://docker.m.daocloud.io",
    "https://huecker.io"
  ]
}

Note: Mirrors may become invalid over time, please search for available mirror sources.

Reload configuration and restart service:

bash
sudo systemctl daemon-reload
sudo systemctl restart docker

All resources are from the open-source community. Disclaimer