在 alpine linux 容器中构建 docker 图像
Building docker image, inside an alpine linux container
我们正在使用 docker 个容器 运行ning alpine linux 作为 bamboo 中的构建代理。作为构建计划的一部分,需要创建 docker 图像。
我们的构建代理已安装 docker,但是我们遇到错误,因为 docker 守护程序未 运行ning。使用
启动守护进程
/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 在 alpine 上不适用。
运行 Docker 容器内的 Docker 守护进程通常是一个危险的前景。我们有完全相同的要求,我们通过将 /var/run/docker.sock
从 Docker 主机安装到 Docker 容器中来解决它:
docker run -v /var/run/docker.sock:/var/run/docker.sock --privileged
这样,构建代理容器内的 docker
命令实际上是在与主机上的 Docker 守护进程对话,而不是在容器内。对我们来说真的很好用。
我们正在使用 docker 个容器 运行ning alpine linux 作为 bamboo 中的构建代理。作为构建计划的一部分,需要创建 docker 图像。
我们的构建代理已安装 docker,但是我们遇到错误,因为 docker 守护程序未 运行ning。使用
启动守护进程/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 在 alpine 上不适用。
运行 Docker 容器内的 Docker 守护进程通常是一个危险的前景。我们有完全相同的要求,我们通过将 /var/run/docker.sock
从 Docker 主机安装到 Docker 容器中来解决它:
docker run -v /var/run/docker.sock:/var/run/docker.sock --privileged
这样,构建代理容器内的 docker
命令实际上是在与主机上的 Docker 守护进程对话,而不是在容器内。对我们来说真的很好用。