7

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.

Santhosh
  • 9,965
  • 20
  • 103
  • 243

2 Answers2

2

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.

King Chung Huang
  • 5,026
  • 28
  • 24
1

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.

Guido U. Draheim
  • 3,038
  • 1
  • 20
  • 19