H
H
hancack2021-04-25 19:11:00
linux
hancack, 2021-04-25 19:11:00

How to execute systemctl daemon-reload inside Docker container?

Hello! I recently ran into a problem while setting up a custom service (daemon) inside a Docker container, and so far I haven't been able to find a solution.

So, the situation is as follows: I have a custom.service file, which contains all the service settings (by the way, the service works without problems on the host). I move this file to the /etc/systemd/system/ folder, where the files of other services are stored. After moving this file to the directory, you need to execute the systemctl daemon-reload command, but here a problem appears - the lack of systemctl in the docker, and, therefore, the inability to execute daemon-reload, which updates the list of available services in the system, as I understand it. To start the daemon, I just need to add a custom service to the system.

I'm sure that someone has already encountered the same problem, but I could not find a solution. If you know how to fix this, maybe there are some alternatives to this command, then please tell me, I will be very grateful. Thank you!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vadim, 2021-04-25
@Viji

the solution is so-so, but something can be pulled out from here...
https://forums.docker.com/t/systemctl-status-is-no...

M
Maxim Grishin, 2021-04-26
@vesper-bot

I think you have an XY problem. You want to run a service in docker, but instead of looking for options to run it in docker, you grab systemctl. Build a separate container for the service and run it.

A
Andrey, 2021-05-23
@Barm0leykin

In general, the Docker ideology is one process - one container. That is, according to Feng Shui, you need a second container for your daemon, or as an option, teach your applications to receive commands via api and process new inputs without rebooting.
But if you really want to make a virtual machine inside the docker with services, cron, init scripts and other joys, then there is this thing: https://github.com/phusion/baseimage-docker . It uses not systemd, but runit, but the meaning is the same

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question