1

In my Dockerfile, I have the following:

    git clone https://github.com/gdraheim/docker-systemctl-replacement /opt/systemctl-github && \
    rm /usr/bin/systemctl && \
    ln -s /opt/systemctl-github/files/docker/systemctl.py /usr/bin/systemctl && \
    ls -lh /usr/bin/systemctl && \
    /usr/bin/systemctl stop amazon-ssm-agent && \

However, when the docker container is being built, it complains about not being able to find /usr/bin/systemctl. The command right before it calls ls on it, which shows it in the docker build process, so not quite sure I understand why.

Here's what the docker build shows:

Cloning into '/opt/systemctl-github'...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed100 29.6M  
100 29.6M    0     0  14.1M      0  0:00:02  0:00:02 --:--:-- 14.1M

lrwxrwxrwx 1 root root 47 Dec 12 21:04 /usr/bin/systemctl -> /opt/systemctl-github/files/docker/systemctl.py
/bin/sh: 1: /usr/bin/systemctl: not found

Any idea why this is saying /usr/bin/systemctl is not found, although ls shows it right there in the output?

LewlSauce
  • 5,326
  • 8
  • 44
  • 91
  • Possible duplicate (just one of the first in my search): https://stackoverflow.com/q/51767316/596285 – BMitch Dec 12 '21 at 23:46
  • Docker containers usually don't use `systemctl` at all. Systemd is a heavy-weight tool that tries to manage many parts of a Linux system that aren't accessible in containers, and in any case it won't be running during an image build. Do you have a more complete example showing how this fits into your Dockerfile? Does anything bad happen if you delete this code block entirely? – David Maze Dec 13 '21 at 00:26
  • 1
    I'm using this to stop/restart services that don't appear to work without `systemctl`. So if I remove it, there are some errors that will occur during runtime that depend on restarting services. – LewlSauce Dec 16 '21 at 14:33

0 Answers0