Quantcast
Channel: Active questions tagged dockerfile - DevOps Stack Exchange
Viewing all articles
Browse latest Browse all 142

systemd in Docker/Podman: how to start a service within `RUN`?

$
0
0

So this works, at least in podman, to run unaltered debian with systemd started:

ARG IMAGE_BASE='debian'ARG IMAGE_TAG='stable-slim'FROM ${IMAGE_BASE}:${IMAGE_TAG}RUN apt-get -qq update && \    apt-get -qq install -y ca-certificates systemd systemd-sysv && \    rm -rf /var/lib/apt/lists/* && \    find /etc/systemd/system \        /lib/systemd/system \        -path '*.wants/*' \        -not -name '*journald*' \        -not -name '*systemd-tmpfiles*' \        -not -name '*systemd-user-sessions*' \        -delete -print && \    systemctl set-default multi-userSTOPSIGNAL SIGRTMIN+3ENTRYPOINT ["/sbin/init"]

But how do I add something during this process that uses systemd? - Like say:

apt-get install -y nginx && systemctl reload nginx

I tried explicitly running /sbin/init and storing its pid for killing, or even an explicit run of /usr/lib/systemd/systemd --system --unit=basic.target which left me with a "can only run on PID 1" error.

My goal is using Dockerfiles to test installers without any alterations. Switching to OpenRC is a non-option.


Viewing all articles
Browse latest Browse all 142

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>