Where do args passed to systemd have to reside?

Arguments or -flags can be passed to systemd systemctl when e.g. starting a service.

But do the args need to reside in

  1. the service
  2. systemd
  3. somewhere else

In other words, must the args be callable to/by the service itself (as I assume)?

Asked By: Johan


Arguments usually live in the service file in the ExecStart= line.

# /lib/systemd/system/myservice.service
ExecStart=/bin/myprogram arg1 arg2

One of the links you provided uses templated services to define one of the arguments

# /lib/systemd/system/myservice@.service
ExecStart=/bin/myprogram %i


That will let you enable multiple instance of the same service with different arguments.

systemctl enable --now myservice@arg1.service
systemctl enable --now myservice@arg2.service

That will cause two instances to run, with different arguments: /bin/myprogram arg1 and /bin/myprogram/arg2.

is it possible to start a service without it opening a GUI?

Now you’re getting specific. It sounds like you have a service which launches a GUI that manages docker. In that case I suspect systemd is the wrong place to look. Your docker-desktop.service probably doesn’t run any of your containers, but just provides an interface to interact with the service that does. That service could manage all container instances as child processes without systemd involved.

Take a look (just guessing) at

systemctl list-units *docker*

I bet that will reveal the actual service that is responsible for managing your containers.

Docker containers don’t usually require an executive like this, and it is often possible to manage them via systemd, but you need to have a .service file for each container, each with its own set of arguments.

Answered By: Stewart
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.