linux - docker 可以在 Linux 容器中运行吗?

标签 linux docker lxc

Koding是一个协作编程环境,它为多个用户创建一个虚拟机来协作进行软件开发。他们使用 Linux 容器来虚拟化机器。我无法在上面安装 docker:

tiagoboldt@vm-2:~$ sudo docker build -t mongo .       
[sudo] password for tiagoboldt:          
Uploading context 645.1 kB
Uploading context 
Step 0 : FROM ubuntu:latest                                                                                                                                                                                      
Pulling repository ubuntu                                                                                                                                                                                        
9cd978db300e: Error pulling image (latest) from ubuntu, endpoint: https://cdn-registry-1.docker.io/v1/, Driver aufs failed to get image rootfs 6170bb7b0ad1003a827e4dc5253ba49f6719599eac485db51eaafd507c13c311: 
9cd978db300e: Error pulling image (latest) from ubuntu, Driver aufs failed to get image rootfs 6170bb7b0ad1003a827e4dc5253ba49f6719599eac485db51eaafd507c13c311: permission denied                               
6170bb7b0ad1: Error downloading dependent layers                                                                                                                                                                 

2014/02/28 03:32:55 build: pull: Could not find repository on any of the indexed registries.

任何人都可以建议安装 docker 的解决方法吗?

最佳答案

是的,docker 可以在 linux 容器中运行。

但 docker 只能在 lxc 执行驱动程序和 unconfined lxc 中运行。

那么,下面是如何在 LXC 中获取 docker:

  1. 确保您有 lxc.aa_profile = lxc-container-default-with-nesting(如果它不起作用或您没有此配置文件,请尝试 lxc .aa_profile = unconfined) 在 LXC 的 config 文件中,以确保它不会被 apparmor 阻止。如需更多信息,请访问(或修改)/etc/apparmor.d/lxc 中的文件。

  2. 你需要在你的容器中安装 lxc。例如,如果您在 ubuntu 下,请在容器中运行 apt-get install lxc

  3. 确保使用 --exec-driver=lxc 参数调用 docker 守护程序。您可以通过手动发出 docker -d --exec-driver=lxc 来测试它。在 ubuntu 中,要在启动时使用参数,只需编辑 /etc/default/docker 并确保您有以下行:

DOCKER_OPTS="--exec-driver=lxc"

关注此线程以获取更新:https://github.com/docker/docker/issues/6783

如果需要排错:

  • 密切关注主机内核日志中的 apparmor 日志。
  • 手动启动 docker -d ... 以获取输出。

注意:您可能无法通过判断其他人的答案来修改 Koding 上的 LXC apparmor 脚本,无论如何,如果您是 LXC 提供者,这个方法仍然很有趣,它回答了您遇到的更普遍的问题在您的问题标题中提出,这可能会在更一般的情况下吸引人们(就像我一样)。

关于linux - docker 可以在 Linux 容器中运行吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22085657/

相关文章:

linux - 2个命名空间之间的连接

mongodb - 如何分析 Docker 容器的磁盘使用情况

c - 文件描述符自动更新到文件末尾

linux - maven 不下载依赖项,因为 trustAnchors 参数必须非空

c# - Docker 容器无法启动

docker - 将 docker 卷挂载到主机路径

docker - 去构建 : build output "api" already exists and is a directory

linux - libvirt lxc 错误消息

linux - 我无法重新启动我的 dnsmasq 服务,所以我的雾服务器无法工作

c++ - 如何解决 linux 定时器信号处理程序