|
@@ -1,77 +1,81 @@
|
|
% docker
|
|
% docker
|
|
|
|
|
|
-# Remove an image
|
|
|
|
|
|
+# 删除镜像 Remove an image
|
|
docker image rm <image_id>
|
|
docker image rm <image_id>
|
|
|
|
|
|
-# Delete an image from the local image store
|
|
|
|
|
|
+# 从本地镜像存储中删除镜像 Delete an image from the local image store
|
|
docker rmi <image_id>
|
|
docker rmi <image_id>
|
|
|
|
|
|
-# Clean none/dangling images
|
|
|
|
|
|
+# 清理无标签/悬空的镜像 Clean none/dangling images
|
|
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
|
|
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
|
|
|
|
|
|
-# Force clean none/dangling images
|
|
|
|
|
|
+# 强制清理无标签/悬空的镜像 Force clean none/dangling images
|
|
docker rmi $(docker images --filter "dangling=true" -q --no-trunc) -f
|
|
docker rmi $(docker images --filter "dangling=true" -q --no-trunc) -f
|
|
|
|
|
|
-# List all images that are locally stored with the Docker engine
|
|
|
|
|
|
+# 列出本地存储的所有镜像 List all images that are locally stored with the Docker engine
|
|
docker images
|
|
docker images
|
|
|
|
|
|
-# Build an image from the Dockerfile in the current directory and tag the image
|
|
|
|
|
|
+# 从当前目录的 Dockerfile 构建镜像并打标签 Build an image from the Dockerfile in the current directory and tag the image
|
|
docker build -t <image>:<version> .
|
|
docker build -t <image>:<version> .
|
|
|
|
|
|
-# Pull an image from a registry
|
|
|
|
|
|
+# 从镜像仓库拉取镜像 Pull an image from a registry
|
|
docker pull <image>:<version>
|
|
docker pull <image>:<version>
|
|
|
|
|
|
-# Stop a running container through SIGTERM
|
|
|
|
|
|
+# 通过 SIGTERM 停止正在运行的容器 Stop a running container through SIGTERM
|
|
docker stop <container_id>
|
|
docker stop <container_id>
|
|
|
|
|
|
-# Stop a running container through SIGKILL
|
|
|
|
|
|
+# 通过 SIGKILL 强制停止正在运行的容器 Stop a running container through SIGKILL
|
|
docker kill <container_id>
|
|
docker kill <container_id>
|
|
|
|
|
|
-# List the networks
|
|
|
|
|
|
+# 列出所有网络 List the networks
|
|
docker network ls
|
|
docker network ls
|
|
|
|
|
|
-# List the running containers
|
|
|
|
|
|
+# 列出正在运行的容器 List the running containers
|
|
docker ps
|
|
docker ps
|
|
|
|
|
|
-# Delete all running and stopped containers
|
|
|
|
|
|
+# 删除所有正在运行和已停止的容器 Delete all running and stopped containers
|
|
docker rm -f $(docker ps -aq)
|
|
docker rm -f $(docker ps -aq)
|
|
|
|
|
|
-# Create a new bash process inside the container and connect it to the terminal
|
|
|
|
|
|
+# 在容器内创建一个新的 bash 进程并连接到终端 Create a new bash process inside the container and connect it to the terminal
|
|
docker exec -it <container_id> bash
|
|
docker exec -it <container_id> bash
|
|
|
|
|
|
-# Print the last lines of a container's logs
|
|
|
|
|
|
+# 打印容器日志的最后 100 行 Print the last lines of a container's logs
|
|
docker logs --tail 100 <container_id> | less
|
|
docker logs --tail 100 <container_id> | less
|
|
|
|
|
|
-# Print the last lines of a container's logs and following its logs
|
|
|
|
|
|
+# 打印容器日志的最后 100 行并持续跟踪日志 Print the last lines of a container's logs and following its logs
|
|
docker logs --tail 100 <container_id> -f
|
|
docker logs --tail 100 <container_id> -f
|
|
|
|
|
|
-# Create new network
|
|
|
|
|
|
+# 创建新网络 Create new network
|
|
docker network create <network_name>
|
|
docker network create <network_name>
|
|
|
|
|
|
|
|
+# 获取镜像 ID (示例命令,需根据实际情况调整) Get image ID (example command, adjust as needed)
|
|
$ image_id: docker images --- --headers 1 --column 3
|
|
$ image_id: docker images --- --headers 1 --column 3
|
|
|
|
+
|
|
|
|
+# 获取容器 ID (示例命令,需根据实际情况调整) Get container ID (example command, adjust as needed)
|
|
$ container_id: docker ps --- --headers 1 --column 1
|
|
$ container_id: docker ps --- --headers 1 --column 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
% docker-compose
|
|
% docker-compose
|
|
|
|
|
|
-# Builds, (re)creates, starts, and attaches to containers for all services
|
|
|
|
|
|
+# 构建、创建、启动并附加到所有服务的容器 Builds, (re)creates, starts, and attaches to containers for all services
|
|
docker-compose up
|
|
docker-compose up
|
|
|
|
|
|
-# Builds, (re)creates, starts, and dettaches to containers for all services
|
|
|
|
|
|
+# 构建、创建、启动并分离所有服务的容器 Builds, (re)creates, starts, and detaches to containers for all services
|
|
docker-compose up -d
|
|
docker-compose up -d
|
|
|
|
|
|
-# Builds, (re)creates, starts, and attaches to containers for a service
|
|
|
|
|
|
+# 构建、创建、启动并附加到指定服务的容器 Builds, (re)creates, starts, and attaches to containers for a service
|
|
docker-compose up -d <service_name>
|
|
docker-compose up -d <service_name>
|
|
|
|
|
|
-# Builds, (re)creates, starts, and dettaches to containers for a service
|
|
|
|
|
|
+# 构建、创建、启动并分离指定服务的容器 Builds, (re)creates, starts, and detaches to containers for a service
|
|
docker-compose up -d <service_name>
|
|
docker-compose up -d <service_name>
|
|
|
|
|
|
-# Print the last lines of a service’s logs
|
|
|
|
|
|
+# 打印指定服务日志的最后 100 行 Print the last lines of a service’s logs
|
|
docker-compose logs --tail 100 <service_name> | less
|
|
docker-compose logs --tail 100 <service_name> | less
|
|
|
|
|
|
-# Print the last lines of a service's logs and following its logs
|
|
|
|
|
|
+# 打印指定服务日志的最后 100 行并持续跟踪日志 Print the last lines of a service's logs and following its logs
|
|
docker-compose logs -f --tail 100 <service_name>
|
|
docker-compose logs -f --tail 100 <service_name>
|
|
|
|
|
|
-# Stops containers and removes containers, networks created by up
|
|
|
|
|
|
+# 停止并删除由 `up` 创建的容器和网络 Stops containers and removes containers, networks created by up
|
|
docker-compose down
|
|
docker-compose down
|
|
|
|
+
|