overexchange
overexchange

Reputation: 1

Could not edit systemd service file

Need to edit following entries:

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

in /lib/systemd/system/docker.service file


$ sudo -E systemctl edit docker.service
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2376 --containerd=/run/containerd/containerd.sock

did not update the service file after restart(sudo systemctl restart docker.service)


Edit

On AWS EC2, below is the issue:

$ nano /etc/systemd/system/docker.service.d/override.conf
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

/lib/systemd/system/docker.service still shows unmodified


1) What is the recommended approach to edit service file(docker.service)?

2) Why /lib/systemd/system/docker.service cannot be edited directly?

Upvotes: 2

Views: 14253

Answers (1)

mchawre
mchawre

Reputation: 12268

You need to create a systemd drop-in file for docker.service.

  • Create /etc/systemd/system/docker.service.d/override.conf file with contents
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2376 --containerd=/run/containerd/containerd.sock
  • Reload systemd unit files.
systemctl daemon-reload

NOTE: Reloading systemctl daemon is required after editing any systemd unit file that's as per systemd design. For more info check this.

  • Restart docker daemon.
systemctl restart docker

You need to restart docker daemon to pick up the latest updated systemd unit file.

For more info check this.

Upvotes: 1

Related Questions