Solve the invalid/etc/default/docker issue in debian8, debian8docker
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
Process
At the beginning, I just wanted to add a registry--insecure-registry=192.168.11.33:5000
As the startup parameter of docker daemon. In/etc/default/docker
AddDOCKER_OPTS="$DOCKER_OPTS --insecure-registry=192.168.11.33:5000"
In this way, 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:/lib/systemd/system/docker.service
The EnvironmentFile variable is not set at all, meaning/etc/docker/default is not read at all. The modification method in issue is: Modify/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
Adding to ExecStart should mean letting systemd put EnvironmentFile$DOCKER_OPTS
As the docker startup parameter. However, this does not work for me. If you are successful, please let me know. The cause of the error is$DOCKER_OPTS
It seems that it has not been resolved. docker directly uses/usr/bin/docker -d $DOCKER_OPTS -H fd://
Start, instead/usr/bin/docker -d --insecure-registry=192.168.11.33:5000 -H fd://
So docker will have an error of startup.
$ 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
Here, we can see the docker documentation on systemd, which is actually used here.$OPTIONS
The example of parameter startup is persistent at the time. The result is displayed on a stackoverflow$OPTIONS
Started. 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 it accordingly./lib/systemd/system/docker.service
:
➜ ~ 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
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.