3

Current setup
I've installed the Docker (19.03.11) on Ubuntu (20.04) based on this article: https://docs.docker.com/engine/install/ubuntu/

What would be the goal
I would like to change the data-root and tls options so I search for the config possibilities.

What options I used
- /lib/systemd/system/docker.service
- /etc/docker/daemon.json (not exits by default!)
- /etc/init/docker.conf
- /etc/default/docker
- /etc/init.d/docker
The procedure I followed
I tried all these files with the following procedures:
service docker stop
[edit the file]
systemctl daemon-reload
service docker start

What worked somehow
I can only apply the data-root option by edit the docker.service file (however) it was reset when I instelled the docker-compose, so I guess the solution is not there.

Questions:
- What did I miss that cause the above solutions are not working?
- Any more option where could I pass arguments to the dockerd executable? (beside I manually start it or create my own script in the init.d folder)

1
  • Note to self: Don't forget to check the logs e.g. journalctl -u docker.service Commented May 5 at 2:55

2 Answers 2

3

From what I understand, you can only get the changes you want when you edit the file /lib/systemd/system/docker.service? Is that correct? But it gets overwritten afterwards?

You need to create a systemd drop-in file. Instructions can be found at: https://unix.stackexchange.com/a/468067/105418.

systemctl edit docker.service

That will create a custom file in /etc/systemd/system that will contain the overrides, i.e., the specific settings you wish docker to use. Thus the file in /lib/systemd/system/docker.service can be updated by others, such as docker-compose, without deleting your settings.

PS - Ubuntu 20.04 by default uses systemd and you should be using the systemctl command to start and stop docker.service.

1
  • The issue is with the exec start. Orinially it's ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock but I need it to be ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --data-root=/opt/docker. If I override the execstart and some other components change it, it won't work as I override with mine right?
    – Péter
    Commented Jun 14, 2020 at 15:15
0

Try creating /etc/docker/daemon.json with the following contents

{
    "storage-driver": "overlay2",
    "data-root": "/home/docker"
}

dockerd will automatically pick up the configuration from that file. You do not have to modify the systemd unit configuration file. Here is a complete reference of dockerd options.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .