在Linux操作上,docker守護進程配置文件的默認位置是/etc/docker/daemon.json。可以通過–config-file標志指定非默認位置。下面是Linux操作系統上允許的配置選項完整示例:
{
“authorization-plugins”: [],
“data-root”: “”, # docker的根目錄 (默認值: “/var/lib/docker”)
“dns”: [],
“dns-opts”: [],
“dns-search”: [],
“exec-opts”: [],
“exec-root”: “”,
“experimental”: false,
“features”: {},
“storage-driver“: “”, # docker使用的存儲驅動
“storage-opts”: [],
“labels”: [],
“live-restore”: true,
“log-driver“: “json-file”, # docker的日志驅動,此處的值為json-file
“log-opts”: { # docker的日志設置
“max-size”: “10m”, # docker的日志大小為10m
“max-file”:”5″, # 最大保留5個日志文件
“labels”: “somelabel”,
“env”: “os,customer”
},
“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”: “”, # 設置日志層次 (“debug”|”info”|”warn”|”error”|”fatal”) (默認值為: “info”)
“tls”: true,
“tlsverify”: true,
“tlscacert”: “”,
“tlscert”: “”,
“tlskey”: “”,
“swarm-default-advertise-addr”: “”,
“api-cors-header”: “”,
“selinux-enabled”: false,
“userns-remap”: “”,
“group”: “”,
“cgroup-parent”: “”,
“default-ulimits”: {
“nofile”: {
“Name”: “nofile”,
“Hard”: 64000,
“Soft”: 64000
}
},
“init”: false,
“init-path”: “/usr/libexec/docker-init”,
“ipv6”: false, # 是否啟用ipv6網絡
“iptables”: false, # 是否啟用iptables規則,默認值為true
“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”, # docker的默認運行時環境
“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”
]
}
},
“default-address-pools”:[
{“base”:”172.80.0.0/16″,”size”:24},
{“base”:”172.90.0.0/16″,”size”:24}
]
}
在編輯daemon.json后,需要通過執行下面的命令對docker進行重啟。
systemctl daemon-reload
systemctl restart docker