Chuyển đổi miễn phí

Lệnh Docker Bảng gian lận

Bảng cheat lệnh Docker toàn diện. Tìm kiếm hơn 70 lệnh Docker cần thiết kèm theo ví dụ, mô tả và sao chép bằng một cú nhấp chuột.

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

Về công cụ này

Hướng dẫn tham khảo nhanh toàn diện về các lệnh docker. Duyệt qua các lệnh, cú pháp và ví dụ thường dùng được sắp xếp theo danh mục. Có thể tìm kiếm và thân thiện với thiết bị di động — đánh dấu trang này để truy cập ngay khi bạn cần lời nhắc nhanh.

Cách sử dụng

  1. Duyệt qua các phần tham khảo được phân loại.
  2. Sử dụng thanh tìm kiếm để tìm các lệnh hoặc cú pháp cụ thể.
  3. Nhấp vào bất kỳ mục nào để xem ví dụ sử dụng và giải thích.
  4. Sao chép lệnh trực tiếp để sử dụng trong terminal hoặc trình soạn thảo của bạn.

Câu hỏi thường gặp

Tài liệu tham khảo này có được cập nhật không?
Tài liệu tham khảo bao gồm các lệnh và cú pháp được sử dụng rộng rãi, ổn định trên các phiên bản. Để biết các bổ sung mới nhất hoặc các tính năng dành riêng cho phiên bản, hãy kiểm tra tài liệu chính thức.
Tôi có thể sử dụng tính năng này ngoại tuyến không?
Sau khi tải, trang hoạt động mà không cần kết nối internet. Đánh dấu nó để truy cập nhanh - tất cả nội dung được hiển thị trong trình duyệt mà không cần yêu cầu mạng thêm.
Đây có phải là toàn diện hay chỉ là những điều cơ bản?
Nó bao gồm các lệnh và mẫu được sử dụng phổ biến nhất để xử lý 90% công việc hàng ngày. Đối với các tính năng thích hợp hoặc nâng cao, hãy tham khảo tài liệu chính thức.
Tôi có thể đề xuất bổ sung không?
Chúng tôi thường xuyên cập nhật tài liệu tham khảo của chúng tôi. Nếu bạn nhận thấy các lệnh bị thiếu hoặc có đề xuất, hãy cho chúng tôi biết thông qua trang liên hệ của chúng tôi.