0

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.

2

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.

| improve this answer | |
  • Can you give the command to check the service target – Uday Kiran Reddy Jun 24 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. – Henrik Pingel Jun 24 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 – Uday Kiran Reddy Jun 24 at 16:19
  • This answer really helps. – vijayraj34 Sep 22 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.