Open hlobit opened 3 years ago
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 postgresql@.service
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.
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
Use case:
docker-systemctl-replacement
v1.5.4260 on adebian:stable
docker containerapt-get update
andapt-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 usesystemctl 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/postgresql@11-main.service -> /lib/systemd/system/postgresql@.service