docker-systemctl-replacement icon indicating copy to clipboard operation
docker-systemctl-replacement copied to clipboard

Generators support ?

Open hlobit opened this issue 4 years ago • 2 comments

Use case:

  • install docker-systemctl-replacement v1.5.4260 on a debian:stable docker container
  • apt-get update and apt-get install postgresql
  • systemctl start postgresql

I got the same result reported on issue #77, the systemctl shows the service is running, but no postgresql process is running at all. The workaround to get the service running was to use systemctl start postgresql@11-main.

After going deeper in debian packaging of postgresql to track the issue, I discovered the generators feature of systemd.

A script at /lib/systemd/system-generators/postgresql-generator generates the service as a symlink:

/run/systemd/generator/postgresql.service.wants/[email protected] -> /lib/systemd/system/[email protected]

hlobit avatar Nov 18 '20 22:11 hlobit

Actually, the whole template and generator features of systemd is a bad approach in the world of containers. If multiple instances of a service are needed then multiple containers should be started.

Nethertheless, template units do work - that's the [email protected] part that you see. And the support is needed for some applications which only have the implementation of the start/stop in there.

Your workaround looks completely correct. You could flesh that out with using drop-in parts to patch the postgresql.service replacing the generator call with a direct symlink creation.

https://github.com/gdraheim/docker-systemctl-replacement/blob/master/EXTRA-CONFIGS.md

By the way, debian support is still missing in the examples which is the reason that I did miss the change. The sister project serves also as a test suite for real world services - and postgres is one of the main things that should work of course.

https://github.com/gdraheim/docker-systemctl-images

gdraheim avatar Nov 19 '20 11:11 gdraheim

I have added test_318 to docker-systemctl-images and well, the setup for postgres ubuntu has a few differences.

https://github.com/gdraheim/docker-systemctl-images/blob/develop/ubuntu18-postgres.dockerfile

gdraheim avatar Nov 27 '20 05:11 gdraheim