Docker 命令备忘单

常见 Docker 容器、镜像、网络和卷命令的快速参考。

Basics
docker version

Show Docker version information

Basics
docker info

Display system-wide information

Images
docker pull <image>

Pull an image or a repository from a registry

Images
docker images

List images

Images
docker rmi <image>

Remove one or more images

Images
docker build -t <tag> .

Build an image from a Dockerfile

Containers
docker run -it <image> /bin/bash

Run a command in a new container interactively

Containers
docker run -d -p 80:80 <image>

Run container in background and publish ports

Containers
docker ps

List running containers

Containers
docker ps -a

List all containers (running and stopped)

Containers
docker stop <container>

Stop one or more running containers

Containers
docker rm <container>

Remove one or more containers

Volumes
docker volume ls

List volumes

Volumes
docker volume create <name>

Create a volume

Docker Compose
docker-compose up -d

Build, (re)create, start, and attach to containers

Docker Compose
docker-compose down

Stop and remove containers, networks, images, and volumes