Vinícius Krolow

Let's hurt the code!

Sun, Mar 27, 2016

DOCKER_OPTS not working in ubuntu 16.04


In ubuntu 16.04 docker was not loading the DOCKER_OPTS from /etc/default/docker file, so I was not able to change DNS of docker global.

After search a bit i found that issue with a explanation of why it was not working.

So basically the systemd docker configuration (/lib/systemd/system/docker.service) is not using the /etc/default/docker, the problem is solved by adding an EnvironmentFile directive and modify command to include the options from file:

EnvironmentFile=-/etc/default/docker
ExecStart=/usr/bin/docker daemon $DOCKER_OPTS -H fd://


In the end /lib/systemd/system/docker.service looks like:

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target docker.socket
Requires=docker.socket

[Service]
Type=notify
EnvironmentFile=-/etc/default/docker
ExecStart=/usr/bin/docker daemon $DOCKER_OPTS -H fd://
MountFlags=slave
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
TimeoutStartSec=0

[Install]
WantedBy=multi-user.target

Once edited, I have saved and restarted the docker service, and voila DOCKER_OPTS was working and my docker images are getting the right DNS.

Hey, have you find a typo or english smell? help me improve my english, i'll be glad to receive an improvement here.