跳至主要內容
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

請將尖括號內的任何內容替換為你自己的數值。指令均源自官方文件,且範例均在所示版本上實際執行。