How can I keep my Docker data root settings persistent after updates?

July 6, 2025 2 answers
Asked by !!please clarify
I'm having an issue with my Docker setup where I always add `--data-root /home/docker/` to the ExecStart line in my `/lib/systemd/system/docker.service` file. However, whenever I update Docker, this modification gets wiped out, and I have to keep re-adding it. Is there a way to make sure this setting stays in place after updates? Thanks for your help!

Answers

snowshoe_trail
You really shouldn't be editing `docker.service` directly in the `/lib/systemd/system/` directory. Instead, you can use the systemd override feature. Just run `systemctl edit docker.service`, and it'll create an override config for you. You only need to specify the changes you want, and the rest will remain as is. Check out the docs on override configurations for more details.

page-by-page: I tried editing, but I get a message saying the temporary file is empty. Any idea why? I reopen the file, and it doesn't change.

v9_formant: While this is a solid approach, you can also set this using the `daemon.json` file for a more straightforward setup!

Reply to this answer
shelf life skeptic
Another way to handle this is by editing the `daemon.json` file found at `/etc/docker/daemon.json`. It's a good alternative and is documented well in Docker's official docs if you need to reference it.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions