2

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.

1 Answer 1

7

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.

4
  • Can you give the command to check the service target Jun 24, 2020 at 16:06
  • You can find the path to the unit file (servicename.service) by running systemctl status servicename the path should be in the 2nd line. Jun 24, 2020 at 16:08
  • It 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 Jun 24, 2020 at 16:19
  • This answer really helps.
    – vijayraj34
    Sep 22, 2020 at 7:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .