Solve the invalid/etc/default/docker issue in debian8.
Problem
Environment: Debian 8 + Docker 1.6
Problem:
The DOCKER_OPTS parameter in/etc/default/docker is invalid./etc/default/docker didn't work DOCKER_OPTS do not work
In the beginning, you just set up a registry and want to add -- insecure-registry = 192.168.11.33: 5000 as the startup parameter of docker daemon. Add DOCKER_OPTS = "$ DOCKER_OPTS -- insecure-registry = 192.168.11.33: 5000" in/etc/default/docker to set the DOCKER_OPTS parameter. Then restart docker with service or systemctl.
However, it does not work at all. Docker client fails to access the registry because of tls. If you view docker startup parameters:
? ~ ps -ef | grep dockerroot 11085 1 0 20:32 ? 00:00:00 /usr/bin/docker -d -H fd://angryro+ 11148 1554 0 20:33 pts/1 00:00:00 grep --color=auto docker
The DOCKER_OPTS parameter is not read at all. Find this issue on github. The operating system is also debian and docker 1.6.2. The reason is that the EnvironmentFile variable is not set in/lib/systemd/system/docker. service, which means/etc/docker/default is not read at all. The modification method in issue is:/lib/systemd/system/docker. service:
[Unit] Description = Docker Application Container EngineDocumentation = http://docs.docker.comAfter routing network.tar get docker. socketRequires = docker. socket [Service] EnvironmentFile =-/etc/default/docker # The EnvironmentFile parameter ExecStart =/usr/bin/docker-d $ DOCKER_OPTS-H fd is added here: // # added the batch get
After the EnvironmentFile variable =-Indicates ignore_errors = yes, $ DOCKER_OPTS should be added to ExecStart, which means that systemd uses $ DOCKER_OPTS in EnvironmentFile as the docker startup parameter. However, this does not work for me. If you are successful, please let me know. The error occurs because $ DOCKER_OPTS does not seem to be parsed. docker directly starts with/usr/bin/docker-d $ DOCKER_OPTS-H fd, instead of/usr/bin/docker-d -- insecure-registry = 192.168.11.33: 5000-H fd: //, docker may have a startup error.
$ Ps-ef | grep docker # Check whether docker is started and the startup parameters $ sudo systemctl status docker # view docker startup status $ sudo journalctl-u docker # view docker startup logs
See the docker documentation about systemd, here. in fact, an example of starting with the $ OPTIONS parameter is provided here, but it was persistent at the time. As a result, I finally saw starting with $ OPTIONS on a stackoverflow, so that the modification was successful. Write down the following Debugging commands:
$ sudo systemctl show docker | grep EnvironmentFileEnvironmentFile=-/etc/sysconfig/docker (ignore_errors=yes)$ sudo systemctl status docker | grep Loaded Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled)$ sudo grep EnvironmentFile /usr/lib/systemd/system/docker.serviceEnvironmentFile=-/etc/default/docker
Solution
In/etc/default/docker, use the OPTIONS Option and modify/lib/systemd/system/docker. service accordingly:
? ~ cat /etc/default/docker # Docker Upstart and SysVinit configuration file# Customize location of Docker binary (especially for development testing).#DOCKER="/usr/local/bin/docker"# Use DOCKER_OPTS to modify the daemon startup options.#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"# If you need Docker to use an HTTP proxy, it can also be specified here.#export http_proxy="http://127.0.0.1:3128/"# This is also a handy place to tweak where Docker's temporary files go.#export TMPDIR="/mnt/bigdrive/docker-tmp"OPTIONS=--insecure-registry 192.168.11.33:5000? ~ cat /lib/systemd/system/docker.service [Unit]Description=Docker Application Container EngineDocumentation=http://docs.docker.comAfter=network.target docker.socketRequires=docker.socket[Service]EnvironmentFile=-/etc/default/dockerExecStart=/usr/bin/docker -d -H fd:// $OPTIONSMountFlags=slaveLimitNOFILE=1048576LimitNPROC=1048576LimitCORE=infinity[Install]WantedBy=multi-user.target? ~ sudo systemctl daemon-reload ? ~ sudo systemctl restart docker? ~ ps -ef | grep dockerroot 5516 1 40 21:10 ? 00:00:02 /usr/bin/docker -d -H fd:// --insecure-registry 192.168.11.33:5000angryro+ 5552 1573 0 21:10 pts/0 00:00:00 grep --color=auto docker