shutdown and systemctl are not found in any directory in the Redis (Debian GNU) container… here is a solution to the problem.
shutdown and systemctl are not found in any directory in the Redis (Debian GNU) container
I’m trying to issue a close command on a redis container. The image I use is redis.
I tried all of the following:
shutdown -h now
/sbin/shutdown -h now
/bin/shutdown -h now
systemctl poweroff
They all said they couldn’t find the order.
Operating system information: (from cat/etc/*-release
).
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Solution
The image you use does not contain these binaries, nor should it contain them, especially systemctl.
Containers should initialize as quickly as possible, and having a fully functional initialization system again serves this purpose because they impose overhead.
This is why smaller initialization systems are used to handle containers, such as tini
Keep in mind that containers are processes that run in the host kernel, so you should stop and start them from the host. Docker has all the utilities you need to do this.