Docker, System has not been booted with systemd as init system (PID 1). Can't operate
Docker is designed around the idea of a single service per container. While there are workarounds to get systemd running in a container those are AFAIK only useful in the context of ci test jobs.
Instead of starting the process with systemctl
find the actual command executed by systemd
when running systemctl start servicename
by looking for the ExecStart
instruction in the unit file of the service. That is the command (you might need to adjust it a bit) which should be set as the CMD
instruction in the Dockerfile.
Uday Kiran Reddy
Updated on September 18, 2022Comments
-
Uday Kiran Reddy about 1 year
I am trying to create docker container for one of the centos service created by us.
We have 2 rpm files.
After installing on base image of centos 8.
I installed those 2 rpm files in it.
But, when I try to start the service, I am getting this error. when I ran systemctl start <service_name>
System has not been booted with systemd as init system (PID 1). Can't operate
Failed to connect to bus: Host is down
Based, on the feedback of different posts, I tried creating container with below steps.
docker run -it -p 8080:80 -p 16700:16700 centos
docker run -it -p 8080:80 -p 16700:16700 --privileged=true centos
Both same issue. Please suggest.
-
Uday Kiran Reddy over 3 yearsCan you give the command to check the service target
-
Henrik Pingel over 3 yearsYou can find the path to the unit file (
servicename.service
) by runningsystemctl status servicename
the path should be in the 2nd line. -
Uday Kiran Reddy over 3 yearsIt is showing a sh file in the ExecStart. When I ran that sh, it is not showing any output. But, below is the contents of the sh file. codeshare.io/anZROX
-
vijayraj34 about 3 yearsThis answer really helps.