免費轉換器

Docker 命令 速查表

全面的 Docker 命令速查表。搜尋 70+ 個必備 Docker 命令,附帶範例、說明和一鍵複製功能。

docker run
Create and start a new container from an image
範例:docker run -d -p 80:80 --name web nginx
docker run -it
Run a container interactively with a terminal
範例:docker run -it ubuntu bash
docker run --rm
Run a container and remove it automatically when it exits
範例:docker run --rm alpine echo 'hello'
docker run -e
Set environment variables in a container
範例:docker run -e NODE_ENV=production node:18
docker run -v
Mount a volume or bind mount into a container
範例:docker run -v /host/path:/container/path nginx
docker start
Start one or more stopped containers
範例:docker start my-container
docker stop
Stop one or more running containers gracefully
範例:docker stop my-container
docker restart
Restart one or more containers
範例:docker restart my-container
docker rm
Remove one or more stopped containers
範例:docker rm my-container
docker rm -f
Force-remove a running container
範例:docker rm -f my-container
docker ps
List running containers
範例:docker ps
docker ps -a
List all containers including stopped ones
範例:docker ps -a
docker exec
Run a command in a running container
範例:docker exec -it my-container bash
docker logs
Fetch logs from a container
範例:docker logs -f --tail 100 my-container
docker inspect
Return low-level information about a container or image
範例:docker inspect my-container
docker stats
Display live resource usage statistics for containers
範例:docker stats my-container
docker top
Display running processes inside a container
範例:docker top my-container
docker pause
Pause all processes within a container
範例:docker pause my-container
docker unpause
Unpause all processes within a paused container
範例:docker unpause my-container
docker rename
Rename an existing container
範例:docker rename old-name new-name
docker kill
Kill a running container by sending a signal
範例:docker kill --signal=SIGTERM my-container
docker cp
Copy files between a container and the host filesystem
範例:docker cp my-container:/app/config.json ./config.json
docker attach
Attach local I/O streams to a running container
範例:docker attach my-container
docker pull
Download an image from a registry
範例:docker pull nginx:latest
docker push
Upload an image to a registry
範例:docker push myuser/myimage:v1.0
docker build
Build an image from a Dockerfile
範例:docker build -t myapp:latest .
docker build --no-cache
Build an image without using the layer cache
範例:docker build --no-cache -t myapp:latest .
docker images
List all locally available images
範例:docker images
docker rmi
Remove one or more images
範例:docker rmi nginx:old myimage:v1
docker tag
Create a tag referencing a source image
範例:docker tag myapp:latest myuser/myapp:v2.0
docker history
Show the history of an image's layers
範例:docker history nginx:latest
docker save
Save an image to a tar archive
範例:docker save -o myimage.tar myapp:latest
docker load
Load an image from a tar archive
範例:docker load -i myimage.tar
docker import
Import a tarball to create a filesystem image
範例:docker import mycontainer.tar myimage:imported
docker export
Export a container's filesystem as a tar archive
範例:docker export my-container > mycontainer.tar
docker commit
Create a new image from a container's changes
範例:docker commit my-container myimage:snapshot
docker image prune
Remove unused (dangling) images
範例:docker image prune -a
docker network create
Create a new network
範例:docker network create --driver bridge my-network
docker network ls
List all networks
範例:docker network ls
docker network rm
Remove one or more networks
範例:docker network rm my-network
docker network inspect
Show detailed information about a network
範例:docker network inspect my-network
docker network connect
Connect a running container to a network
範例:docker network connect my-network my-container
docker network disconnect
Disconnect a container from a network
範例:docker network disconnect my-network my-container
docker network prune
Remove all unused networks
範例:docker network prune
docker volume create
Create a named volume
範例:docker volume create my-volume
docker volume ls
List all volumes
範例:docker volume ls
docker volume rm
Remove one or more volumes
範例:docker volume rm my-volume
docker volume inspect
Display detailed information about a volume
範例:docker volume inspect my-volume
docker volume prune
Remove all unused local volumes
範例:docker volume prune
docker compose up
Create and start all services defined in compose file
範例:docker compose up -d
docker compose down
Stop and remove containers, networks from compose
範例:docker compose down --volumes
docker compose ps
List containers for a compose project
範例:docker compose ps
docker compose logs
View output from compose service containers
範例:docker compose logs -f web
docker compose build
Build or rebuild services defined in compose file
範例:docker compose build --no-cache web
docker compose pull
Pull service images defined in the compose file
範例:docker compose pull
docker compose restart
Restart service containers
範例:docker compose restart web
docker compose exec
Execute a command in a running service container
範例:docker compose exec web bash
docker compose run
Run a one-off command on a service
範例:docker compose run --rm web npm test
docker compose stop
Stop running containers without removing them
範例:docker compose stop web
docker compose config
Validate and view the merged compose configuration
範例:docker compose config
docker info
Display system-wide Docker information
範例:docker info
docker version
Show the Docker client and daemon version
範例:docker version
docker system df
Show disk usage by Docker objects
範例:docker system df -v
docker system prune
Remove all unused Docker resources at once
範例:docker system prune -a --volumes
docker events
Stream real-time events from the Docker daemon
範例:docker events --filter type=container
docker login
Log in to a Docker registry
範例:docker login registry.example.com
docker logout
Log out from a Docker registry
範例:docker logout registry.example.com
docker search
Search Docker Hub for images
範例:docker search --filter stars=100 nginx
docker context ls
List available Docker contexts
範例:docker context ls
docker context use
Switch the active Docker context
範例:docker context use my-remote-host

關於此工具

docker 指令的綜合快速參考指南。瀏覽按類別組織的常用指令、語法和範例。可搜尋且適合行動裝置 - 將此頁面加入書籤,以便在需要快速提醒時即時存取。

使用方法

  1. 瀏覽分類的參考部分。
  2. 使用搜尋欄尋找特定指令或語法。
  3. 按一下任何條目即可查看使用範例和說明。
  4. 直接複製命令以在終端機或編輯器中使用。

常見問題

該參考文獻是最新的嗎?
該參考涵蓋了廣泛使用的命令和語法,這些命令和語法在各個版本中都是穩定的。有關最新添加或特定於版本的功能,請查看官方文件。
我可以離線使用嗎?
加載後,該頁面無需互聯網連接即可運行。將其新增為書籤以便快速存取 - 所有內容都在瀏覽器中呈現,無需進一步的網路請求。
這是全面的還是只是基礎知識?
它涵蓋了處理 90% 日常任務的最常用命令和模式。有關利基或高級功能,請參閱官方文件。
我可以建議補充嗎?
我們定期更新我們的參考資料。如果您發現缺少命令或有建議,請透過我們的聯絡頁面告知我們。