Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker archlinux image: System has not been booted with systemd as init system (PID 1). Can't operate

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.

like image 697
Santhosh Avatar asked Mar 04 '19 03:03

Santhosh


2 Answers

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.

like image 77
King Chung Huang Avatar answered Sep 25 '22 06:09

King Chung Huang


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.

like image 40
Guido U. Draheim Avatar answered Sep 24 '22 06:09

Guido U. Draheim