0

Currently I've configured my docker usingn /etc/docker/daemon.json

    "hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2376"],
    "tls": true,
    "tlscacert": "/data/certs/ca.pem",
    "tlscert": "/data/certs/server-cert.pem",
    "tlskey": "/data/certs/server-key.pem",
    "containerd": "/run/containerd/containerd.sock",
    "tlsverify": true
}

and /lib/systemd/system/docker.service on ubuntu 20.04 server

ExecStart=
ExecStart=/usr/bin/dockerd

The problem is that every time I make an update of my OS, the file /lib/systemd/system/docker.service is overwrited and docker cannot start until I modify the file docker.sesrvice again

Are there something more that I need to do in order to avoid this issue or my config files are wrong.

Thanks in advance

overraidy
  • 13
  • 2

1 Answers1

1

When making changes to systemd units, never modify the units that ship with a package (as they may be updated/replaced when the package is updated). Instead, use a "drop-in" (override) unit to override options.

Refer to Control Docker with systemd in the documentation.

Override files need to be put in a specific location for systemd to load them (e.g. /etc/systemd/system/docker.service.d/override.conf).

The easiest way to create an override file, is to use systemctl edit <name of service>. For example systemctl edit docker.service. This will open an empty file with the correct name/location in your default editor, in which you can specify the overrides.

After saving the file, you can view all active systemd units for a service using systemctl cat <service name> (systemctl cat docker.service). If those look correct, run systemctl daemon-reload and systemctl restart docker.service to have the new configuration take effect.

thaJeztah
  • 27,738
  • 9
  • 73
  • 92