gpt4 book ai didi

docker - 在 Alpine linux容器内构建docker镜像

转载 作者:行者123 更新时间:2023-12-02 19:09:32 38 4
gpt4 key购买 nike

我们将运行Alpine Linux的Docker容器用作Bamboo中的构建代理。作为构建计划的一部分,需要创建docker镜像。

我们的构建代理已安装了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在 Alpine 上已不是问题。

最佳答案

在Docker容器中运行Docker守护程序通常是一个令人生畏的前景。我们有完全相同的要求,我们通过将/var/run/docker.sock从Docker主机安装到Docker容器中来解决此问题:

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

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

关于docker - 在 Alpine linux容器内构建docker镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42275098/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com