Running systemctl within dockerfile



I am trying to run an application that consists of two separate Python-Sub-Applications on an enabled Raspberry Pi.

On a non enabled Raspberry Pi I am using systemctl for this and create two different services which are started during boot up of the device.

So I am looking for a way to use systemctl within a Dockerfile. Is this possible? Any sample of how such a dockerfile would look like is greatly appreciated!




Hi @simonkemper,

I’d guess you can copy the service files in your Dockerfile to the and then use systemctl enable on them? The relevant sections cut out of a Dockerfile would be these:

COPY myservice.service /lib/systemd/system/
RUN systemctl enable myservice.service

See the code in this example project:

Is this what you are looking for?


This is exactly what I was looking for. I’ll give it a try and get back with details!