14

Is it possible to start services on and post startup in CentOS/Fedora distributions without using systemd (systemctl)? If yes, how?

Systemd does not work in non-privileged docker containers; consequently at this point I can only start services within privileged containers, which I'd prefer not to do.

Thanks.

2
  • You could use a cronjob with the @reboot trigger if your cron supports that feature.
    – Marco
    Feb 26, 2015 at 18:37
  • Or you can do something in the login shell: pgrep somed || somed... This obviously only works if you login with a shell, though... Mar 3, 2015 at 16:58

2 Answers 2

14

There is an excellent project -- docker-systemctl-replacement where you can get alternative systemctl command to start/stop services without systemd.

systemctl replacement is not a complete re-implementation of original systemctl but it works fairly well in practice.

It can be installed as follows:

wget https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl.py -O /usr/local/bin/systemctl
2
  • 5
    For newer system(which uses Python3 as default, like Ubuntu 20.04), usesystemctl3.py instead of systemctl.py . Jan 13, 2021 at 9:24
  • 1
    @onlyjob I was facing the same need. This answer and the above comment (about python3) saved my life. Thank you! =:)
    – NYCeyes
    Mar 19, 2021 at 23:07
0

Generally, the model right now is to just start your application directly as the single process in the container. This approach has its flaws, but also seems to be the current main thinking of containerization efforts.

The other models — containers as something more like a lightweight vm, with more supporting infrastructure running — is useful too, but currently we (I work on Fedora) don't have a built-in / predefined model for multi-service containers other than systemd. The goal is eventually to make systemd work in unprivileged containers too. (See Container Interface spec for upstream plans, or this post from Dan Walsh giving a quick update of work in Fedora.) In the meantime, some people have hacked it into working — see this blog post for example.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .