docker配置文件
本人在初学docker的时候,感觉对于docker的配置文件有点搞不定,一会是/etc/sysconfig/docker,一会是/etc/docker/daemon.json,一会是/etc/systemd/system/docker.service.d目录下,更有甚者是/usr/lib/systemd/system/docker.service。
比如配置一个INSECURE-REGISTRY,就可以在/etc/sysconfig/docker文件里添加,也可以在/etc/docker/daemon.json文件里添加。特别的,这两个文件里的格式还不一样!!
这些配置文件到底是什么关系呢?是怎么被docker加载生效的呢?下文简单讲述他们之间的关系及docker的一些配置文件规划。
- 拿到一台主机,用systemctl status docker查看docker的运行状态:
可以看到,加载的其实是/usr/lib/systemd/system/docker.service这个文件。
- 个人认为docker也发现自己的配置文件太分散了,所以搞了一个/etc/docker/daemon.json,但是这个文件默认是不存在的,需要我们手动的去创建(不知道为什么不默认帮我们创建好,就算帮用户创建一个空的文件也行啊!)。
有了这个文件,我们一些常规的配置,都可以统一在这个文件里进行设置了,如下是/etc/docker/daemon.json的所有配置项:
{ "authorization-plugins": [], "data-root": "", "dns": [], "dns-opts": [], "dns-search": [], "exec-opts": [], "exec-root": "", "experimental": false, "storage-driver": "", "storage-opts": [], "labels": [], "live-restore": true, "log-driver": "", "log-opts": {}, "mtu": 0, "pidfile": "", "cluster-store": "", "cluster-store-opts": {}, "cluster-advertise": "", "max-concurrent-downloads": 3, "max-concurrent-uploads": 5, "default-shm-size": "64M", "shutdown-timeout": 15, "debug": true, "hosts": [], "log-level": "", "tls": true, "tlsverify": true, "tlscacert": "", "tlscert": "", "tlskey": "", "swarm-default-advertise-addr": "", "api-cors-header": "", "selinux-enabled": false, "userns-remap": "", "group": "", "cgroup-parent": "", "default-ulimits": {}, "init": false, "init-path": "/usr/libexec/docker-init", "ipv6": false, "iptables": false, "ip-forward": false, "ip-masq": false, "userland-proxy": false, "userland-proxy-path": "/usr/libexec/docker-proxy", "ip": "0.0.0.0", "bridge": "", "bip": "", "fixed-cidr": "", "fixed-cidr-v6": "", "default-gateway": "", "default-gateway-v6": "", "icc": false, "raw-logs": false, "allow-nondistributable-artifacts": [], "registry-mirrors": [], "seccomp-profile": "", "insecure-registries": [], "no-new-privileges": false, "default-runtime": "runc", "oom-score-adjust": -500, "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服务,让其加载生效。
# systemctl daemon-reload
# systemctl restart docker
- daemon.json里的内容记不住怎么办?
# man dockerd
相关推荐
yangkang 2020-09-10
王道革 2020-11-25
bwyyziq 2020-11-22
pigsmall 2020-11-19
changecan 2020-11-19
helloWorldAndYou 2020-11-16
nginxs 2020-11-14
红石丶 2020-11-13
WanKaShing 2020-11-12
yangkang 2020-11-12
滴水穿石点石成金 2020-11-12
张荣珍 2020-11-12
wuxunanjing 2020-11-11
魅惑青花瓷 2020-11-11
lihongtai 2020-11-09
yangkang 2020-11-09
worldsnow 2020-11-06
MichaelJScofield 2020-11-06