問題:DOCKER_OPTS參數不生效
最近更新了docker版本Docker version 18.03.1-ce, build 9ee9f40
,更新docker源的時候發現,修改/etc/default/docker
後,使用docker info
查看相關配置,配置無更新,即DOCKER_OPTS
參數無法生效。
原因
在新的版本中,/etc/default/docker
默認不生效=。= 需要進行手動配置,使其生效。
官方說明:
## 1.12.0 (2016-07-28)
**IMPORTANT**: Docker 1.12 ships with an updated systemd unit file for rpm
based installs (which includes RHEL, Fedora, CentOS, and Oracle Linux 7). When
upgrading from an older version of docker, the upgrade process may not
automatically install the updated version of the unit file, or fail to start
the docker service if;
- the systemd unit file (`/usr/lib/systemd/system/docker.service`) contains local changes, or
- a systemd drop-in file is present, and contains `-H fd://` in the `ExecStart` directive
雖然說文檔上說docker.service
這個文件會在/usr/lib/systemd/system/
下,但其真實路徑是路徑是/lib/systemd/system/
。該路徑是在默認的安裝腳本中指定的systemd/docker.service lib/systemd/system/
。
解決
1、在/lib/systemd/system/docker.service
中添加EnvironmentFile=-/etc/default/docker
,並修改ExecStart參數爲ExecStart=/usr/bin/dockerd -H fd:// $DOCKER_OPTS
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
EnvironmentFile=-/etc/default/docker
ExecStart=/usr/bin/dockerd -H fd:// $DOCKER_OPTS
ExecReload=/bin/kill -s HUP $MAINPID
2、重啓docker-daemon
systemctl daemon-reload
3、重啓docker
service docker restart