docker参数说明

Docker 命令参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
[root@hadoop01 ~]# docker

Usage: docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
--config string Location of client config files (default "/root/.docker")
-c, --context string Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context
set with "docker context use")
-D, --debug Enable debug mode
-H, --host list Daemon socket(s) to connect to
-l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default "/root/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default "/root/.docker/cert.pem")
--tlskey string Path to TLS key file (default "/root/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit

Management Commands:
builder Manage builds
config Manage Docker configs
container Manage containers
context Manage contexts
engine Manage the docker engine
image Manage images
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes

Commands:
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes

Run 'docker COMMAND --help' for more information on a command.

Docker配置文件

Docker 的配置文件可以设置大部分的后台进程参数,文件路径:

  • ubuntu 中的位置:/etc/default/docker/daemon.json

  • centos6 中的位置:/etc/sysconfig/docker/daemon.json

  • centos7 中的位置:/etc/docker/daemon.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{
"authorization-plugins": [],//访问授权插件
"data-root": "",//docker数据持久化存储的根目录
"dns": [],//DNS服务器
"dns-opts": [],//DNS配置选项,如端口等
"dns-search": [],//DNS搜索域名
"exec-opts": [],//执行选项
"exec-root": "",//执行状态的文件的根目录
"experimental": false,//是否开启试验性特性
"storage-driver": "",//存储驱动器
"storage-opts": [],//存储选项
"labels": [],//键值对式标记docker元数据
"live-restore": true,//dockerd挂掉是否保活容器(避免了docker服务异常而造成容器退出)
"log-driver": "",//容器日志的驱动器
"log-opts": {},//容器日志的选项
"mtu": 0,//设置容器网络MTU(最大传输单元)
"pidfile": "",//daemon PID文件的位置
"cluster-store": "",//集群存储系统的URL
"cluster-store-opts": {},//配置集群存储
"cluster-advertise": "",//对外的地址名称
"max-concurrent-downloads": 3,//设置每个pull进程的最大并发
"max-concurrent-uploads": 5,//设置每个push进程的最大并发
"default-shm-size": "64M",//设置默认共享内存的大小
"shutdown-timeout": 15,//设置关闭的超时时限(who?)
"debug": true,//开启调试模式
"hosts": [],//监听地址(?)
"log-level": "",//日志级别
"tls": true,//开启传输层安全协议TLS
"tlsverify": true,//开启输层安全协议并验证远程地址
"tlscacert": "",//CA签名文件路径
"tlscert": "",//TLS证书文件路径
"tlskey": "",//TLS密钥文件路径
"swarm-default-advertise-addr": "",//swarm对外地址
"api-cors-header": "",//设置CORS(跨域资源共享-Cross-origin resource sharing)头
"selinux-enabled": false,//开启selinux(用户、进程、应用、文件的强制访问控制)
"userns-remap": "",//给用户命名空间设置 用户/组
"group": "",//docker所在组
"cgroup-parent": "",//设置所有容器的cgroup的父类(?)
"default-ulimits": {},//设置所有容器的ulimit
"init": false,//容器执行初始化,来转发信号或控制(reap)进程
"init-path": "/usr/libexec/docker-init",//docker-init文件的路径
"ipv6": false,//开启IPV6网络
"iptables": false,//开启防火墙规则
"ip-forward": false,//开启net.ipv4.ip_forward
"ip-masq": false,//开启ip掩蔽(IP封包通过路由器或防火墙时重写源IP地址或目的IP地址的技术)
"userland-proxy": false,//用户空间代理
"userland-proxy-path": "/usr/libexec/docker-proxy",//用户空间代理路径
"ip": "0.0.0.0",//默认IP
"bridge": "",//将容器依附(attach)到桥接网络上的桥标识
"bip": "",//指定桥接ip
"fixed-cidr": "",//(ipv4)子网划分,即限制ip地址分配范围,用以控制容器所属网段实现容器间(同一主机或不同主机间)的网络访问
"fixed-cidr-v6": "",//(ipv6)子网划分
"default-gateway": "",//默认网关
"default-gateway-v6": "",//默认ipv6网关
"icc": false,//容器间通信
"raw-logs": false,//原始日志(无颜色、全时间戳)
"allow-nondistributable-artifacts": [],//不对外分发的产品提交的registry仓库
"registry-mirrors": [],//registry仓库镜像
"seccomp-profile": "",//seccomp配置文件
"insecure-registries": [],//非https的registry地址
"no-new-privileges": false,//禁止新优先级(??)
"default-runtime": "runc",//OCI联盟(The Open Container Initiative)默认运行时环境
"oom-score-adjust": -500,//内存溢出被杀死的优先级(-1000~1000)
"node-generic-resources": ["NVIDIA-GPU=UUID1", "NVIDIA-GPU=UUID2"],//对外公布的资源节点
"runtimes": {//运行时
"cc-runtime": {
"path": "/usr/bin/cc-runtime"
},
"custom": {
"path": "/usr/local/bin/my-runc-replacement",
"runtimeArgs": [
"--debug"
]
}
}
}

参考

docker 各种参数配置

docker 的常用参数和解析

-------------本文结束感谢您的阅读-------------