linux - 在 Redis (Debian GNU) 容器的任何目录中都找不到 shutdown 和 systemctl
问题描述
我正在尝试在 redis 容器上发出关闭命令。我使用的图像是redis
.
我尝试了以下所有方法:
shutdown -h now
/sbin/shutdown -h now
/bin/shutdown -h now
systemctl poweroff
他们都说找不到命令。
操作系统信息:(来自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/"
解决方案
您使用的图像不包含这些二进制文件,尤其是 systemctl。
容器应该尽可能快地初始化,并且拥有一个功能齐全的初始化系统会再次达到这个目的,因为它们会产生开销。
这就是为什么使用较小的 init 系统来处理容器的原因,例如tini。
请记住,容器是在主机内核中运行的进程,因此您应该从主机停止和启动它们。Docker 具有执行此操作所需的所有实用程序。
推荐阅读
- r - geom_smooth 公式中的小写到大写影响线性回归绘图
- python - 编写一个将信息存储在字典中的函数。Python3 错误:“语法错误:‘返回’外部函数”
- python - AttributeError:“顺序”对象没有属性“ndim”
- c# - ASP.NET Core MVC 过滤器是单例吗?
- string - 使用 reflect.StringHeader 将字节转换为字符串仍然分配新内存?
- python - VS Code 继续使用过时的 Python 解释器运行 Python 脚本,即使在指定了预期的解释器之后也是如此
- laravel - 如何使用 laravel 从不同的行数据更新一行
- laravel-5 - 从 laravel API 检索数据到颤振应用程序
- python - Random.sample 输出一个 3 维数组
- deep-learning - 用于混合数据降维的自动编码器