6

Since 16.04 release Ubuntu stopped using Upstart and switch to Systemd for its init system.

How can I change default DOCKER_OPTS parameters?

luka5z
  • 7,525
  • 6
  • 29
  • 52
  • This question is closely linked to http://stackoverflow.com/questions/33784295/setting-dns-for-docker-daemon-on-os-with-systemd?rq=1 . – luka5z Sep 13 '16 at 15:46

1 Answers1

12

Execute following commands as root (or with sudo).

To extend the default docker unit file with additional configuration options, first create a configuration directory in /etc/systemd/system/:

mkdir /etc/systemd/system/docker.service.d/

Now put a configuration file in /etc/systemd/system/docker.service.d/. It's imperative that the file name must end with the .conf suffix:

touch /etc/systemd/system/docker.service.d/docker.conf

To change daemon parameters create configuration file with following content (ex. adds --dns option):

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// --dns 8.8.8.8

After saving docker unit file, before systemd will take it into account, systemd needs to reload modified data:

systemctl daemon-reload 

Finally docker service can be restarted:

systemctl restart docker

You can check that status by running:

systemctl status docker.service | grep dns

Default

On Ubuntu default configuration is located in /lib/systemd/system/docker.service.

Resources

Yann Vo
  • 1,793
  • 1
  • 15
  • 10
luka5z
  • 7,525
  • 6
  • 29
  • 52
  • 2
    To simplify things you can use `systemctl edit docker.service` and this will open docker.service file in a text editor no matter the location. – krzysiej Nov 24 '17 at 07:53