wzg0wzg 2020-05-14
本人在初学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的一些配置文件规划。
可以看到,加载的其实是/usr/lib/systemd/system/docker.service这个文件。
有了这个文件,我们一些常规的配置,都可以统一在这个文件里进行设置了,如下是/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" ] } } }
# systemctl daemon-reload
# systemctl restart docker
# man dockerd