Docker Centos7 : Failed to mount tmpfs as/run: Operation not permitted

标签 docker centos centos7 docker-container systemctl

所以我想让 systemctl 在 docker 容器上工作以进行分配,所以我使用了命令:

docker run --privileged -ti  -e container=docker -v /sys/fs/cgroup:/sys/fs/cgroup s3696653/usap-a1 usr/sbin/init

一切运行良好,但我还没有完全阅读规范,我们不应该使用 systemctl。所以我停止了容器并尝试像平常一样运行容器:

docker run -i -t s3696653/usap-a1

但是它不再起作用了。 我收到错误:

Failed to mount tmpfs as /run: Operation not permitted

[!!!!!!] Failed to mount API filesystems, freezing.

我该怎么做才能使用正常的运行命令运行它? 提前致谢。

最佳答案

虽然建议不要在容器内使用 systemd 或使用特权模式,但建议并不是法令,如果不严格遵守,新泽西州警察会在晚上把你拖走并带走。如果您使用 --privilegedged 运行它,接下来尝试看看在没有它的情况下运行它需要什么,因为避免它会使您的设置更安全。

使用 -v (由 docker official documentation) 称为绑定(bind)挂载应该可以帮助您传递所需的卷,而不需要 --privileged 选项。事实上,这是来自旧 stackoverflow thread 的 systemd-in-docker 示例,询问类似的问题问题:

docker run -ti --tmpfs /tmp --tmpfs /run -v /sys/fs/cgroup:/sys/fs/cgroup:ro -p 80:80 local/centos7-systemd

关于Docker Centos7 : Failed to mount tmpfs as/run: Operation not permitted,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63717749/

相关文章:

tomcat - Docker 容器间双向通信

authentication - OpenVAS 命令获取 Failed Authentication 错误

php - MySQL PHP 未将完整文件存储到 BLOB

docker - 如何在 CentOS 7 上安装最新版本的 Docker

仅在需要升级时停止服务的 Ansible 方法

linux - 创建和扩展 centos 6-i386 Docker 基础镜像时出现 "cp: Command not found"

java - AWS 上的 Docker JVM CPU 限制

docker - 如何在 Dockerfile 中设置镜像名称?

linux - awk 更新重复数据的时间戳

mysql - 如何清除在 CentOS 7 上运行的 mysqld.log 文件