【问题标题】:How to run docker inside centos 7 lxc?如何在 centos 7 lxc 中运行 docker?
【发布时间】:2018-05-10 10:27:26
【问题描述】:

我可以使用 security.privilegedsecurity.nesting 在 Ubuntu 上正常工作。然而,在 centos7 中,docker 守护进程在尝试拉取图像时会失败。它甚至不能运行 hello-world。存在某些文件夹不存在的 cgroup 冲突。无论如何,有没有这样做的成功例子?我最终尝试运行 Kubernetes 并为 master 和 worker 使用 lxc/lxd 容器,但我需要它在 centos 中工作。 确切的错误信息:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:279: applying cgroup configuration for process caused \"open /sys/fs/cgroup/systemd/lxc/docker-test/docker/cpuset.cpus: no such file or directory\"": unknown. ERRO[0000] error waiting for container: context canceled

Exact setup 是一个安装了 lxd 并从 go 构建的 centos7 Digital Ocean Droplet。使用 lxc 我创建了一个 centos7 容器。在那个机器容器中,我正在尝试运行 docker。我意识到这就像容器启动,但它绝对适用于 ubuntu,所以我想它应该适用于 centos。

【问题讨论】:

  • 确切的错误信息是什么?是否有一些详细的选项可以添加到失败的命令中?
  • 添加到描述中。感谢您的回复。

标签: docker centos lxc cgroups lxd


【解决方案1】:

我在我的 Fedora-28 (LXC) 主机中运行 CentOS-7.6 Linux/LXC 容器 (GUEST) 时遇到了这个问题;尝试在该 CentOS-7.6 LXC 容器中使用 Docker 时。我做了一些研究并从这些网络资源中拼凑出一个解决方案:


解决办法:

jdoe@HOST$ sudo echo "root:1000000:65536" | sudo tee -a /etc/subuid /etc/subgid
# The above is performed once on the LXC HOST! (the outermost server).

# ---------------------------------------------------------------------------------
# Next, add these entries to the config file of the Linux/LXC container giving
# you the exception, (noting that blank 'lxc.cap.drop =' is not a mistake).
# ---------------------------------------------------------------------------------
security.nesting = true
security.privileged = true
lxc.aa_profile = unconfined
lxc.cgroup.devices.allow = a
lxc.mount.auto=proc:rw sys:rw
lxc.cap.drop =
# ---------------------------------------------------------------------------------

这消除了与您的错误非常相似的错误,并使事情正常进行。希望对你有帮助。

【讨论】:

    【解决方案2】:

    在我的例子中,CentOS-7 (LXC) HOST 中的 CentOS-7 LXC 容器 (GUEST),唯一需要的配置是:

    • lxc.cgroup.devices.allow = a
    • lxc.mount.auto=sys
    • lxc.cap.drop =

    与 NYCeyes 帖子相比,以下内容不需要或修改:

    • lxc.mount.auto=proc:rw sys:rw(已删除 proc,docker 错误仅涉及 /sys 中的目录;使用 sys 而不是 sys:rw,因为它更安全,如果好奇 google "man lxc.mount.auto"

      李>
    • (完全删除)security.nesting = true

    • (完全删除)security.privileged = true

    • (完全删除)lxc.aa_profile = unconfined(aa_profile 指 App Armor,CentOS-7 使用 SELinux 而不是 AA)

    • (未执行)sudo echo "root:1000000:65536" | sudo tee -a /etc/subuid /etc/subgid

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-06
      • 2023-03-22
      • 2015-12-12
      • 2018-09-04
      相关资源
      最近更新 更多