How can systemd and systemctl be enabled and used in Ubuntu Docker containers? [closed]

This is by design. Docker should be running a process in the foreground in your container and it will be spawned as PID 1 within the container’s pid namespace. Docker is designed for process isolation, not for OS virtualization, so there are no other OS processes and daemons running inside the container (like systemd, cron, … Read more

What benefit do I get from JSVC over just using systemd?

In general, most of the functionality provided by jsvc is provided by systemd, with the exception of opening of privileged ports (see below). If possible, it is a very good idea to switch to using systemd functionality directly, since things become simpler and more efficient. Your unit file looks mostly OK, with the exception of … Read more

systemctl status shows inactive dead

You have set Type=Forking, but your service doesn’t work. Try Type=oneshot You have a “&” your ExecStart line, which is not necessary. The service is disabled, which means it was not enabled to start at boot. You should run systemctl enable hello to set it to start at boot. You can check man systemd.directives to … Read more

Systemd script does ExecStop right after ExecStart

Type=oneshot is used for units, such as a filesystem check or a cleanup, which execute an action without keeping active processes. Such systemd units will wait until the process specified by ExecStart terminates, and then deactivate by running the process specified by ExecStop. Type=simple (the default setting) is used when the process configured with ExecStart … Read more

docker change cgroup driver to systemd

A solution that does not involve editing systemd units or drop-ins would be to create (or edit) the /etc/docker/daemon.json configuration file and to include the following: { “exec-opts”: [“native.cgroupdriver=systemd”] } After saving it, restart your docker service. sudo systemctl restart docker This solution obviously is only feasible if you would want to apply this system-wide.

When should the option RemainAfterExit needs to be set true when creating new systemd services?

Use RemainAfterExit=yes for services, which somehow change state of the system. When you want that state reverted, you just stop the service. Then you can start it again, but not without first stopping it. An example would be service which creates a flag in filesystem to be used by some other application. When started, it … Read more

Using setup.py to install python project as a systemd service

You get an ImportError, because the module in question is not in sys.path or not accessible, because of some file system permissions. Here’s a script to check file system permissions of a given distribution, group and name. chk_perm.py from pkg_resources import get_distribution import os import sys dist, group, name = sys.argv[1:] dist = get_distribution(dist) location … Read more

systemd: “Environment” directive to set PATH

You can’t use EnvVars in Environment directives. The whole Environment= will be ignored. If you use EnvironmentFile=, then the specified file will be loaded without substitution. So PATH=/local/bin:$PATH would be exactly that, and this is probably not what you want. Under CentOS7 the following works. # /etc/systemd/system/nagios.service.d/env.conf [Service] Environment=”PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin” > sudo systemctl daemon-reload > sudo … Read more