I installed docker image and built a image successfully.
When I ssh to the container and run the command service xxx start
, an error popped:
service nginfra start
Redirecting to /bin/systemctl start nginfra.service /sbin/service: line 79: /bin/systemctl: No such file or directory
Actually, fakesystemd
is installed in the container instead of systemd
.
So I removed fakesystemd
and installed systemd
with the command:
yum swap -- remove fakesystemd -- install systemd systemd-libs
But I still can't start the service:
service nginfra start
Redirecting to /bin/systemctl start nginfra.service Failed to get D-Bus connection: No connection to service manager.
Does anyone ever meet and solved this issue?
This is known issue with systemd
-based OSes inside Docker containers.
Short answer: as well as replacing fakesystemd
with systemd
you need to attach /sys/fs/cgroup
as a read-only volume into the container, build the image and then run it in "privileged" mode.
This is the best guide I've found for this. It uses Centos as the example, but should work with any systemd
-based OS.