在一个高山linux容器里面build造docker图象

我们正在使用运行高山linux的docker容器作为build中的代理。 作为构build计划的一部分,需要创buildDocker镜像。

我们的构build代理已经安装了docker,但是由于docker守护进程没有运行,我们得到了错误。 启动守护进程

/usr/local/bin/dockerd 

给出以下内容:

 INFO[0000] libcontainerd: new containerd process, pid: 640 ERRO[0001] 'overlay' is not supported over overlayfs INFO[0001] Graph migration to content-addressability took 0.00 seconds INFO[0001] Loading containers: start. WARN[0001] Running modprobe bridge br_netfilter failed with message: modprobe: can't change directory to '/lib/modules': No such file or directory , error: exit status 1 WARN[0001] Running modprobe nf_nat failed with message: `modprobe: can't change directory to '/lib/modules': No such file or directory`, error: exit status 1 WARN[0001] Running modprobe xt_conntrack failed with message: `modprobe: can't change directory to '/lib/modules': No such file or directory`, error: exit status 1 Error starting daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain: Iptables not found 

为了解决这个问题,我安装了iptables。 现在,当我尝试运行docker守护进程时,我得到:

 INFO[0000] libcontainerd: new containerd process, pid: 705 ERRO[0001] 'overlay' is not supported over overlayfs INFO[0001] Graph migration to content-addressability took 0.00 seconds INFO[0001] Loading containers: start. WARN[0001] Running modprobe bridge br_netfilter failed with message: modprobe: can't change directory to '/lib/modules': No such file or directory , error: exit status 1 WARN[0001] Running modprobe nf_nat failed with message: `modprobe: can't change directory to '/lib/modules': No such file or directory`, error: exit status 1 WARN[0001] Running modprobe xt_conntrack failed with message: `modprobe: can't change directory to '/lib/modules': No such file or directory`, error: exit status 1 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) 

因为sudo不是阿尔卑斯山上的东西,所以我现在有点卡在现在要去的地方。

在Docker容器内运行Docker守护进程通常是一个狡猾的前景。 我们有完全相同的要求,我们通过将Docker主机的/var/run/docker.sock挂载到Docker容器来解决这个问题:

 docker run -v /var/run/docker.sock:/var/run/docker.sock --privileged 

这样,构build代理容器内的docker命令实际上是与主机上的Docker守护进程对话,而不是在容器内。 对我们真的很好。