Does dist-upgrade replace service files?

I recently noticed a server performing apt-get update && apt-get dist-upgrade

Amongst other things, docker was updated and restarted.

However, I noticed some changes I made to the service file previously were now gone. The file at /lib/systemd/system/docker.service seems to have been reset.

Is this possible? I don't recall if I ran daemon-reload after these changes.

EDIT: To be clear: I'm wondering is dist-upgrade basically removed the service file and replaced it with a default one?

And does daemon-reload prevent this in the future?

EDIT2: Ok, looks like sudo systemctl edit docker.service is the way to go and performs a daemon-reload on save.


Don't edit files in /lib/systemd/ or /usr/share/systemd as they will get overwritten on updates.

Instead, copy the file to /etc/systemd/ and make the changes there.

The /etc/ directory (at least for systemd) is considered the place to store local config files. All other /**/systemd/ directories are considered sources of default and sample config files that should be replaced on any upgrade.

Another reason to not edit these package supplied config files is that if you copy it to /etc/systemd/... and edit it and make a mistake, you can always compare with the original file.

systemctl daemon-reload doesn't prevent anything. It just tells systemd to re-examine all of its config and use whatever has changed.