配置檔案
通用配置檔案 /etc/docker/daemon.json
Docker Engine V1.12 之後版本,使用者可以自行建立 daemon.json 檔案對 Docker Engine 進行配置和調整。要點如下:
- 該檔案作為 Docker Engine 的配置管理檔案, 裡面幾乎涵蓋了所有 docker 命令列啟動可以配置的引數。
- 不管是在哪個平臺以何種方式啟動, Docker 預設都會來這裡讀取配置。使使用者可以統一管理不同系統下的 docker daemon 配置。
- 相關引數的使用說明,可以參閱
man dockerd
幫助資訊,或者參閱官方文件。 - 預設配置檔案目錄及支援的引數說明:
- Linux:
/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": [], "disable-legacy-registry": false, "no-new-privileges": false, "default-runtime": "runc", "oom-score-adjust": -500, "runtimes": { "runc": { "path": "runc" }, "custom": { "path": "/usr/local/bin/my-runc-replacement", "runtimeArgs": [ "--debug" ] } } }
- Windows:
%programdata%\docker\config\daemon.json
,支援的完成引數配置示例如下(最新的支援引數列表可以參閱官方文件):{ "authorization-plugins": [], "data-root": "", "dns": [], "dns-opts": [], "dns-search": [], "exec-opts": [], "experimental": false, "storage-driver": "", "storage-opts": [], "labels": [], "log-driver": "", "mtu": 0, "pidfile": "", "cluster-store": "", "cluster-advertise": "", "max-concurrent-downloads": 3, "max-concurrent-uploads": 5, "shutdown-timeout": 15, "debug": true, "hosts": [], "log-level": "", "tlsverify": true, "tlscacert": "", "tlscert": "", "tlskey": "", "swarm-default-advertise-addr": "", "group": "", "default-ulimits": {}, "bridge": "", "fixed-cidr": "", "raw-logs": false, "allow-nondistributable-artifacts": [], "registry-mirrors": [], "insecure-registries": [], "disable-legacy-registry": false }
- Linux:
不同框架的配置檔案
配置檔案修改說明
- 修改配置後,需要重啟 docker 服務生效。當前主流的 Sytemd 框架相關平臺(CentOS 7+,Ubunt 16+ 等)的重啟指令如下:
systemctl daemon-reolad systemctl restart docker.service
[root@node3 ~]# systemctl start docker.service Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details. [root@node3 ~]# systemctl status docker.service ● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Wed 2017-11-15 15:57:16 CST; 2min 29s ago Docs: https://docs.docker.com Process: 30610 ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0 -H fd:// --dns=223.5.5.5 --dns=223.6.6.6 (code=exited, Main PID: 30610 (code=exited, status=1/FAILURE) Nov 15 15:57:16 c400e32b9e7cd46aea0d484ad260f4e4a-node3 systemd[1]: Starting Docker Application Container Engine... Nov 15 15:57:16 c400e32b9e7cd46aea0d484ad260f4e4a-node3 dockerd[30610]: unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: dns: (from flag: [223.5.5.5 223.6.6.6], from file: [114.114.114.114 8.8.8.8]) Nov 15 15:57:16 c400e32b9e7cd46aea0d484ad260f4e4a-node3 systemd[1]: docker.service: Main process exited, code=exite Nov 15 15:57:16 c400e32b9e7cd46aea0d484ad260f4e4a-node3 systemd[1]: Failed to start Docker Application Container En Nov 15 15:57:16 c400e32b9e7cd46aea0d484ad260f4e4a-node3 systemd[1]: docker.service: Unit entered failed state. Nov 15 15:57:16 c400e32b9e7cd46aea0d484ad260f4e4a-node3 systemd[1]: docker.service: Failed with result 'exit-code'. lines 1-13/13 (END) 複製程式碼