docker-systemctl-replacement: 'systemctl' not working

I have manually copied code from @https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl3.py and pasted in the systemctl3.py using ‘nano’ in a “debian:bookworm-slim” container. then copied the systemctl3.py file as: /usr/bin/systemctl Then if I run: systemctl daemon-reload the output is: root@debian-dev-environment:/# cp systemctl3.py usr/bin/systemctl

root@debian-dev-environment:/# systemctl daemon-reload
ERROR:systemctl:  getty-static.service: Service Executable path is not absolute.
ERROR:systemctl:  initrd-cleanup.service: Service Executable path is not absolute.
ERROR:systemctl:  initrd-parse-etc.service: Service Executable path is not absolute.
ERROR:systemctl:  initrd-switch-root.service: Service Executable path is not absolute.
ERROR:systemctl:  system-update-cleanup.service: Service Executable path is not absolute.
ERROR:systemctl:  systemd-ask-password-console.service: Service Executable path is not absolute.
ERROR:systemctl:  systemd-ask-password-wall.service: Service Executable path is not absolute.
ERROR:systemctl: systemd-exit.service: a .service file without [Service] section
ERROR:systemctl:  systemd-firstboot.service: Service Executable path is not absolute.
ERROR:systemctl:  systemd-halt.service: Service Executable path is not absolute.
ERROR:systemctl:  systemd-journal-flush.service: Service Executable path is not absolute.
ERROR:systemctl:  systemd-journal-flush.service: Service Executable path is not absolute.
ERROR:systemctl:  systemd-kexec.service: Service Executable path is not absolute.
ERROR:systemctl:  systemd-machine-id-commit.service: Service Executable path is not absolute.
ERROR:systemctl:  systemd-networkd.service: Service Executable path is not absolute.
ERROR:systemctl: systemd-poweroff.service: a .service file without [Service] section
ERROR:systemctl: systemd-reboot.service: a .service file without [Service] section
ERROR:systemctl:  systemd-sysext.service: Service Executable path is not absolute.
ERROR:systemctl:  systemd-sysext.service: Service Executable path is not absolute.
ERROR:systemctl:  systemd-sysusers.service: Service Executable path is not absolute.
ERROR:systemctl:  systemd-tmpfiles-clean.service: Service Executable path is not absolute.
ERROR:systemctl:  systemd-tmpfiles-setup-dev.service: Service Executable path is not absolute.
ERROR:systemctl:  systemd-tmpfiles-setup.service: Service Executable path is not absolute.`

if I start or stop a service using systemctl start some.service no error is returned neither the service is started. the same happens when I do systemctl stop some.service

p.s. python3, systemd are already installed into the container

I have reproduced the same problem in my dietpi machine.

Maybe I am doing something wrong. In dire need of help.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

I can confirm having the errors, here is my Dockerfile (it’s a mess and WIP, but you just need to install systemd to have the files. So I used dpkg -L systemd | grep ".service$" | tr '\n' '\0' | xargs -0 -n1 -i rm -v {} to remove them

FROM debian:bullseye

ADD --chmod=444 https://repository.rudder.io/apt/rudder_apt_key.gpg /etc/apt/trusted.gpg.d/rudder_apt_key.gpg

# See: https://github.com/Normation/rudder-packages
RUN echo "deb [signed-by=/etc/apt/trusted.gpg.d/rudder_apt_key.gpg] http://repository.rudder.io/apt/7.2/ bullseye main" > /etc/apt/sources.list.d/rudder.list && \
    apt-get update && \
    apt-get install systemd apache2 rsync gpg python3 -y && \
    # Remove systemd installed services new systemctl does not like them
    dpkg -L systemd | grep ".service$" | tr '\n' '\0' | xargs -0 -n1 -i rm -v {} && \
    apt-get install rudder-external-db -y && \
    apt-get install --download-only rudder-server rudder-relay -y

ADD --chmod=555 https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/v1.5.7106/files/docker/systemctl3.py /bin/systemctl

# See: https://askubuntu.com/a/482936/432270
RUN set -ex; \
    dpkg --unpack /var/cache/apt/archives/rudder-server_*.deb && \
    dpkg --unpack /var/cache/apt/archives/rudder-relay_*.deb && \
    # See: https://github.com/Normation/rudder-packages/pull/2711
    sed -i "s|propertie$|properties|" /opt/rudder/share/package-scripts/rudder-server-postinst && \
    sed -i "s|^systemctl start|#systemctl start|" /opt/rudder/share/package-scripts/rudder-relay-postinst && \
    sed -i "s|^chgrp|#chgrp|" /opt/rudder/bin/rudder-fix-repository-permissions && \
    apt-get install -fy && \
    apt-get clean && \
    rm -rv /var/cache/apt/archives /var/lib/apt/lists/* && \
    rm -rv /var/log/apt/* /var/log/dpkg.log /var/log/alternatives.log

VOLUME ['/opt/rudder/etc/rudder-pkg/rudder-pkg.conf']
CMD /bin/systemctl

Actually, the only problems may come from services which are enabled. There is a blacklist in the source code for some known parts - check “igno_always” having “systemd-*”

Now let’s see what’s left

# dpkg -L systemd | grep \\.service | grep wants | grep -v systemd-
/lib/systemd/system/getty.target.wants/getty-static.service
/lib/systemd/system/sysinit.target.wants/kmod-static-nodes.service

The only thing that stands out is “kmod”. I am adding that to the igno-list.

I can confirm having the errors, here is my Dockerfile (it’s a mess and WIP, but you just need to install systemd to have the files. So I used dpkg -L systemd | grep ".service$" | tr '\n' '\0' | xargs -0 -n1 -i rm -v {} to remove them

FROM debian:bullseye

ADD --chmod=444 https://repository.rudder.io/apt/rudder_apt_key.gpg /etc/apt/trusted.gpg.d/rudder_apt_key.gpg

# See: https://github.com/Normation/rudder-packages
RUN echo "deb [signed-by=/etc/apt/trusted.gpg.d/rudder_apt_key.gpg] http://repository.rudder.io/apt/7.2/ bullseye main" > /etc/apt/sources.list.d/rudder.list && \
    apt-get update && \
    apt-get install systemd apache2 rsync gpg python3 -y && \
    # Remove systemd installed services new systemctl does not like them
    dpkg -L systemd | grep ".service$" | tr '\n' '\0' | xargs -0 -n1 -i rm -v {} && \
    apt-get install rudder-external-db -y && \
    apt-get install --download-only rudder-server rudder-relay -y

ADD --chmod=555 https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/v1.5.7106/files/docker/systemctl3.py /bin/systemctl

# See: https://askubuntu.com/a/482936/432270
RUN set -ex; \
    dpkg --unpack /var/cache/apt/archives/rudder-server_*.deb && \
    dpkg --unpack /var/cache/apt/archives/rudder-relay_*.deb && \
    # See: https://github.com/Normation/rudder-packages/pull/2711
    sed -i "s|propertie$|properties|" /opt/rudder/share/package-scripts/rudder-server-postinst && \
    sed -i "s|^systemctl start|#systemctl start|" /opt/rudder/share/package-scripts/rudder-relay-postinst && \
    sed -i "s|^chgrp|#chgrp|" /opt/rudder/bin/rudder-fix-repository-permissions && \
    apt-get install -fy && \
    apt-get clean && \
    rm -rv /var/cache/apt/archives /var/lib/apt/lists/* && \
    rm -rv /var/log/apt/* /var/log/dpkg.log /var/log/alternatives.log

VOLUME ['/opt/rudder/etc/rudder-pkg/rudder-pkg.conf']
CMD /bin/systemctl

this helped. Thanks

@williamdes - I did use your code but I did need to replace the lines saying “ADD --chmod=444 https” as standard “docker” does not understand those commands. See the code I posted.