【发布时间】:2018-04-12 14:45:33
【问题描述】:
我无法让 Docker CE 在 Ubuntu Docker 映像上运行。这是我的Dockerfile:
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y curl apt-transport-https ca-certificates curl gnupg2 software-properties-common
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
RUN apt-get update && apt-get install -y docker-ce
RUN docker info
最后一个命令失败并显示以下内容:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
如果我尝试从容器中运行 dockerd,它会返回以下内容:
ERRO[2018-04-12T14:35:43.945962200Z] 'overlay2' is not supported over overlayfs
INFO[2018-04-12T14:35:43.974187900Z] Graph migration to content-addressability took 0.00 seconds
INFO[2018-04-12T14:35:43.976355700Z] Loading containers: start.
WARN[2018-04-12T14:35:43.978060300Z] Running modprobe bridge br_netfilter failed with message: , error: exec: "modprobe": executable file not found in $PATH
WARN[2018-04-12T14:35:43.978173000Z] Running modprobe nf_nat failed with message: ``, error: exec: "modprobe": executable file not found in $PATH
WARN[2018-04-12T14:35:43.978965200Z] Running modprobe xt_conntrack failed with message: ``, error: exec: "modprobe": executable file not found in $PATH
Error starting daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain: iptables failed: iptables -t nat -N DOCKER: iptables v1.6.0: can't initialize iptables table `nat': Permission denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.
(exit status 3)
我认为ubuntu 映像的内核中缺少某些内容?
这是来自容器的uname -a 的输出:
root@85bdefe67e4a:/# uname -a
Linux 85bdefe67e4a 4.9.87-linuxkit-aufs #1 SMP Wed Mar 14 15:12:16 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
ubuntu:16.04 容器有问题还是我忘记了什么?
【问题讨论】:
-
只是为了进一步澄清,为什么要在 docker 的容器中运行 docker?
-
今天我将用一个在 docker 中工作的裸骨 docker 来回答你的问题,我在生产中工作得很好......方法是不要将 docker 安装在容器内,而是侧载 docker,以便启用 docker 命令从容器内部... @hichamx 问为什么?因为我的云托管服务提供商无法让我在生产中获得 root 权限,所以我为诸如 github webhook 服务器安装之类的东西进行了所有 root 安装,该安装启动了我的 docker 映像重建并从我的 devops 容器内重新启动......透明、可维护且没有任何第 3 方CI 供应商中间人的怪物
-
出于我的目的(从 BitBucket 管道构建和推送 Docker 映像),我意识到 BitBucket 在@ScottStensland 提到的配置中已经几乎具有此功能:confluence.atlassian.com/bitbucket/…
标签: ubuntu docker containers dockerfile