@utezduyar, as @wjordan mentioned in System has not been booted with systemd as init system (PID 1). Can't operate. - #3 by wjordan, you can start systemd in its own namespace using unshare
:
CMD ["unshare", "--pid", "--fork", "--mount-proc", "/lib/systemd/systemd"]
Then you can use nsenter
to enter the namespace to run systemctl
commands. For example:
nsenter --target $(pidof systemd) --mount --uts --ipc --net --pid -- bash -c "systemctl start <your service>"
However, I’m not sure how reliable your application would be using this approach. As @roadmr said, it needs to be tested.
I’d appreciate your feedback because I’m in a similar situation to yours. If you find a working solution, please share your experience as it would be very helpful for others facing the same issue.