Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change dockerd parameters with systemd? [duplicate]

Tags:

docker

systemd

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

How can I change default DOCKER_OPTS parameters?

like image 693
luka5z Avatar asked Sep 13 '16 15:09

luka5z


1 Answers

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

  • Control and configure Docker with systemd
  • Modifying Existing Unit Files
like image 158
luka5z Avatar answered Nov 16 '22 10:11

luka5z