toolbox: systemctl does not work inside the toolbox
I’m setting up a toolbox for a development environment for a web application that requires postgresql running. I’m installing postgresql-server on the toolbox and then trying to start it using the usual method:
INS mildred@toolbox$ sudo systemctl start postgresql.service
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
This is understandable as I’m running within a container, and systemd usually is not started in containers. Still, it means I have to manually start up postgresql by reading the systemd service file.
It would be great if systemd was started as entrypoint in the toolbox image, instead of sleep +Inf. Of course, udev and low level services would have to be prevented from starting so that a blank toolbox would not start any service.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 17
- Comments: 15 (1 by maintainers)
Commits related to this issue
- Run init system when starting the toolbox Remove PID namespace sharing and run the init system as PID 1 instead of sleep when starting up the toolbox. implements debarshiray/toolbox#176 Shell execut... — committed to mildred/fedora-toolbox by mildred 5 years ago
- Run init system when starting the toolbox Remove PID namespace sharing and run the init system as PID 1 instead of sleep when starting up the toolbox. implements debarshiray/toolbox#176 Shell execut... — committed to mildred/fedora-toolbox by mildred 5 years ago
Yep, it’s possible to execute postgresql in a podman container instead, but you lack the easy use and integration. I believe the toolbox is much more easy to use of you can just
toolbox enterand then start working. Instead if you have to execute some lengthy podman commands outside of the toolbox first, and redirect ports, you are not as productive.Also, podman gave me an error when I tried to start the container, but that’s not an issue with toolbox.
In my case, this issue doesn’t allow to run MongoDB:
toolbox entersudo systemctl enable mongodsystemctl status mongod.service@debarshiray The issue blocks the migration to non-testing usage of ostree-based distros like Silverblue, Gnome OS, Endless OS. Can I hope this problem will be fixed in the short term?
I believe this warrants a separate issue, but I found this because I was investigating using toolbox for debugging and wanted
systemctl status <service>to work inside of it.I was able to get this to work by running:
This issue seems to be more about starting services inside of the toolbox, however. I’m less interested in that, and more interested in making the toolbox as transparent as possible on the host, while still allowing for installing tools, etc. for debugging.
Trying to use nsenter to have systemd running in a PID namespace and toolbox shells running in the host PID namespace does not work so well. the
/procfilesystem mounted within the container represents the container PID namespace and not the host. As such, commands are complaining with errors like:Perhaps we can have different features enabled for the toolboxes, and we can choose for each toolbox if we want to
It corresponds to two different use cases.
Trying out running systemd with the toolbox, I find a problem with it. systemd is not running as PID 1 and tries to start in user mode and not in system mode.
This is because there is the
--pid=hostoption passed topodman create.May I suggest that
podman createkeeps the PID namespace (so systemd can run) butpodman execgets a new option to keep the PID namespace of the host. it is possible with nsenter, why not podman exec ?found a nice post here: https://developers.redhat.com/blog/2019/04/24/how-to-run-systemd-in-a-container/