I tried to make use of the properties considered for unit names containing dashes ("-"-) according to the archlinux man pages, and it worked:
Moreover for unit names containing dashes ("-"
-), the set of directories generated by repeatedly truncating the unit name after all dashes is searched too. Specifically, for a unit name foo-bar-baz.servicefoo-bar-baz.servicenot only the regular drop-in directory foo-bar-baz.service.d/foo-bar-baz.service.d/is searched but also both foo-bar-.service.d/foo-bar-.service.d/and foo-.service.d/foo-.service.d/.
Along with a unit file foo.service
foo.service, a "drop-in" directory foo.service.d/foo.service.d/may exist. All files with the suffix ".conf".conffrom this directory will be merged in the alphanumeric order and parsed after the main unit file itself has been parsed.
In my working example, this is the final structure of the files at the root of my unit search path (i.e., /etc/systemd/system//etc/systemd/system/):
Also, "dockerdocker.conf"conf and "dockerdocker-a.service"service files are:
- Firstly, create a drop-in directory like
"dockerdocker-.service.d"dat the root of a unit search path directory (e.g. /etc/systemd/system/etc/systemd/system). - Then, create a ".conf"
.conffile like"dockerdocker.conf"confat the created drop-in directory and write your[Unit]and[Service]sections in that file using the%jspecifier:
"%j"
%j: This is the string between the last "-"-and the end of the prefix name.
- After that, create one service file for each of your intended services next to the drop-in directory in the root search path. They should just consist of the
[Install]section to explicitly determine their alias name with theAliasoption. (I also tried to put this section in the"dockerdocker.conf"conffile too, but the[Install]section could not be found when the services started.) Be careful that the names of these services should satisfy the constraints. - Now, If you run
systemctl enable docker-{alias}.servicefor each created service, you'll be able to control the service just by its{alias}. That's it!