Docker Community Forums

Share and learn in the Docker community.

Systemd and a 'shell script driven task' together?

(Papadeltasierra) #1

Precis: I want to start Systemd services AND run a shell-script based task in a Docker container - suggestions?

I’ve inherited some CentOS6 based Docker containers that create OVF virtual images. They require the libvirt service to be running which on CentOS6 was not a problem. The container RUN command was used to run a script, the script started the services and all was well.

But on CentOS7, such services are started using Systemd and here my fun starts. All the Systemd examples use RUN to call /bin/init to start Systemd leaving me no ‘hook’ to run my shell script. I’ve also not managed to figure out how to start Systemd from the shell script if I used RUN to start the script (is there some key bit I’ve overlooked?).

So anyone solved this sort of problem already?

FYI, if you’re wondering why, we have a number of products running on different levels of Linux and need to build OVFs, from a single machine, for each of them so Docker has been used to create isolated environments to do this.

(Sam) #2

there is no systemd inside a container.

you are supposed to run ONE thing in a container, and use different containers for multiple things.

(Connectedway) #3

This can be done. I disagree with the comment above that says it’s not meant to run more then one process. That’s just not true. systemd does present some challenges though. And our environment is Yocto based, not CentOS. If you are still running into issues, let me know and I can help you through. I kind of get the feeling that I’m probably one of the few other people doing this with systemd/docker