I am using archlinux/base official image from docker hub.
I am trying to use systemctl and it says.
$ docker run --rm -it ac16c4b756ed systemctl start httpd
System has not been booted with systemd as init system (PID 1). Can't operate.
How to solve this.
If your goal is to run an Apache Web Server (httpd), you should use the httpd image.
Docker containers are generally meant to run a single process. So, you wouldn't normally design a container to run something like systemd as the root process, and then run httpd as a child process. You would just run httpd directly in the foreground. The httpd image does this.
Well, "systemctl" does not do anything by itself but it will ask the systemd daemon to perform some task. It ususally communitcates with it by means of a socket. So the systemd daemon has to be started already. There are some base images which do actually run systemd as PID-1 if needed.
Personally, I would not recommend that however. If you really need to stick with running systemctl commands then you can also try to use the docker-systemctl-replacement script on that operating system as well. It can also serve as the PID-1 of a container.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With