I have a template file (namely /lib/systemd/system/systemd-nspawn@.service) which has an ExecStart entry.

This entry is correct for all services started from that template, except for one. For that special one (say systemd-nspawn@specialcontainer.service) I would like to have a different ExecStart.

For non-template services, I would in that case use a drop-in. Is there an equivalent for template-based service units? I would need a way to inform systemd that this is "a drop-in for the template service unit, when %i is specialcontainer"


Yep - this is possible.

You need to have an override .d folder for the exact service name you want to override - you can see this quite nicely if you do

sudo systemctl edit systemd-nspawn@specialcontainer.service

This will create a file (on my machine at least, running Ubuntu 16.04) at /etc/systemd/system/systemd-nspawn@specialcontainer.service.d/override.conf with changes.

https://askubuntu.com/a/659268/915810 has a way more comprehensive answer - using the getty template systemd unit as an example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.