# 实际上 rmi 是 docker image rm 的一个别名Usage: docker image rm [OPTIONS] IMAGE [IMAGE...]Remove one or more images
Aliases:
rm, rmi, remove
Options:
-f, --force Force removal of the image
--no-prune Do not delete untagged parents
Usage: docker exec[OPTIONS] CONTAINER COMMAND [ARG...]Run a command in a running container
在正在运行的容器中运行命令
Options:
-d, --detach 分离模式:在后台执行命令
--detach-keys string 覆盖分离容器的键序列
-e, --env list 设置环境变量
--env-file list 读入一个环境变量文件
-i, --interactive Keep STDIN open even if not attached
--privileged Give extended privileges to the command -t, --tty Allocate a pseudo-TTY
-u, --user string Username or UID (format: <name|uid>[:<group|gid>]) -w, --workdir string Working directory inside the container
attach: 进入一个现有的终端!容器当前正在运行的终端;相当于附加了一块屏幕
1
2
3
4
5
6
7
8
9
Usage: docker attach [OPTIONS] CONTAINER
Attach local standard input, output, and error streams to a running container
将本地标准输入、输出和错误流附加到正在运行的容器
Options:
--detach-keys string 覆盖分离容器的键序列
--no-stdin 不附加标准din
--sig-proxy 代理进程接收到的所有信号 (default true)
查看日志命令 docker logs
实际上输出的是容器的标准输出和标准错误、
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Usage: docker logs [OPTIONS] CONTAINER
Fetch the logs of a container
Options:
--details 显示提供给日志的额外详细信息
-f, --follow 跟踪日志输出
--since string 显示时间戳后的日志 (e.g. 2013-01-02T13:23:37Z) or
relative (e.g. 42m for42 minutes) -n, --tail string 从日志末尾开始显示的行数 (default "all") -t, --timestamps 显示时间戳
--until string 显示时间戳之前的日志 (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for42 minutes)# 示例1: 显示ID的10条日志并持续输出,显示时间戳docker logs -tf --tail 10 ID
Usage: docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH
Copy files/folders between a container and the local filesystem
在容器和本地文件系统之间复制文件/文件夹
Use '-' as the source to read a tar archive from stdin
and extract it to a directory destination in a container.
使用'-'作为源,从stdin读取tar归档文件,并将其解压缩到容器中的目录目标。
Use '-' as the destination to stream a tar archive of a
container source to stdout.
使用'-'作为目标,将容器源的tar压缩包流到标准输出。
Options:
-a, --archive 归档模式(复制所有uid/gid信息) -L, --follow-link 始终遵循SRC_PATH中的符号链接
# 示例1:复制容器a12中的文件 /applog/root.log 复制到 主机的/root 目录docker cp a12:/applog/root.log /root