簡體   English   中英

如何在centos 7 lxc中運行docker?

[英]How to run docker inside centos 7 lxc?

我讓它在 Ubuntu 上使用security.privilegedsecurity.nesting得很好。 但是在 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

確切的設置是安裝了 lxd 並從 go 構建的 centos7 Digital Ocean Droplet。 我使用 lxc 創建了一個 centos7 容器。 在那個機器容器中,我正在嘗試運行 docker。 我意識到這就像容器啟動一樣,但它絕對適用於 ubuntu,所以我想它應該適用於 centos。

我在 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 =
# ---------------------------------------------------------------------------------

這消除了與您非常相似的錯誤並使事情正常進行。 我希望它有幫助。

在我的 CentOS-7 (LXC) 主機中的 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因為它更安全,如果好奇谷歌"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 sudo echo "root:1000000:65536" | sudo tee -a /etc/subuid /etc/subgid

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM