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.
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 bysystemd
when runningsystemctl start servicename
by looking for theExecStart
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 theCMD
instruction in the Dockerfile.