跳转到主要内容
kitlocal.dev

Docker 与 Compose 速查表

本地运行

100% 在你的浏览器中处理。输入和输出绝不会离开你的设备。

基于 Docker 27+ 的容器生命周期、镜像构建、多阶段 Dockerfile、Compose v2 编排栈、网络、数据卷、日志及安全清理命令。

工作原理

Images are immutable layered templates; containers are writable runtime processes from an image; volumes persist state across container replacement; networks wire service DNS.

生存指南

最先需要掌握的少数几个命令。

42 条命令

键盘快捷键/聚焦搜索框JK移动选择C复制选中命令F收藏选中项Esc清空搜索

Run & Inspect Containers

Start containers, map ports, inspect logs, and attach interactive shells.

  • 基础必备

    Start an ephemeral interactive container and delete it on exit

    docker run --rm -it <image> <shell>

    构建命令

    docker run --rm -it <image> <shell>

    输入的值将按原样插入。若包含空格或特殊字符,请自行添加引号。

    适用场景

    Best for throwaway debugging environments without leaving stopped containers behind.

    命令解析

    --rm
    Automatically remove container once it exits
    -it
    Interactive stdin (-i) + pseudo-TTY (-t)

    示例

    docker run --rm -it alpine:3.20 sh

Images & Multi-Platform Builds

Build, tag, inspect image layers, and manage local registries.

Docker Compose v2

Orchestrate multi-container local stacks cleanly with `docker compose`.

Volumes, Networks & Files

Persist database state, connect containers by service name, and copy files.

Disk Usage & Safe Cleanup

Measure disk consumption and prune unused objects without losing data.

在 KitLocal 工具中试用

核对时间:2026年11月15日 · 核对版本:Docker Engine CLI 27+ & Compose v2

来源: Docker CLI Reference · Docker Compose CLI Reference

请将尖括号内的内容替换为你自己的实际值。所有命令均来自官方文档,示例均在标明版本上实测运行。