If I understand the OP, he is trying to run systemctl within the container. This does not work because systemd is not running within the container to begin with. It cannot be done in unprivileged containers. There is another question here in SO about why he should not run systemd within a container.
I quickly googled and found this 2014 page about using systemd within a container in docker, where there is a short explanation. The fix is to use a privileged container (running docker run --privileged ...
), which is arguably a bad idea but might suit the OP. There is a 2019 update of that last article, and the bottomline is they developed their own container engine (so no docker).
The obvious solution would be to have a single service, so no need for systemd, although that might not be possible in the OP's case.
In summary, possible solutions:
- not to use systemd
- use a privileged container
- not to use docker
systemctl
just don't work inside Docker. You might think of Docker as a way to package an application and not like a full-blown VM with an init system and users and processes; Docker's Containerizing an application tutorial walks through a basic standard use case. – Mollie