在Ubuntu仿生容器中运行Docker

在Ubuntu仿生容器中运行Docker,docker,Docker,我正在最新的Ubuntu Docker映像上安装Docker CE,并出现以下错误。我仔细地遵循安装说明;也许在Docker容器上安装Docker不是解决这个问题的方法?我正在使用Jenkins管道,并在Ubuntu容器上安装了Jenkins;下一步是让Docker运行 time="2018-10-26T13:25:09.920187300Z" level=info msg="scheme \"unix\" not registered, fallback to default scheme"

我正在最新的Ubuntu Docker映像上安装Docker CE,并出现以下错误。我仔细地遵循安装说明;也许在Docker容器上安装Docker不是解决这个问题的方法?我正在使用Jenkins管道,并在Ubuntu容器上安装了Jenkins;下一步是让Docker运行

time="2018-10-26T13:25:09.920187300Z" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
time="2018-10-26T13:25:09.920228600Z" level=info msg="ccResolverWrapper: sending new addresses to cc: [{unix:///var/run/docker/containerd/docker-containerd.sock 0  <nil>}]" module=grpc
time="2018-10-26T13:25:09.920250500Z" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
time="2018-10-26T13:25:09.920286200Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc420047e60, CONNECTING" module=grpc
time="2018-10-26T13:25:09.920480100Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc420047e60, READY" module=grpc
time="2018-10-26T13:25:09.920501400Z" level=info msg="Loading containers: start."
time="2018-10-26T13:25:09.920666400Z" level=warning msg="Running modprobe bridge br_netfilter failed with message: , error: exec: \"modprobe\": executable file not found in $PATH"
time="2018-10-26T13:25:09.920704800Z" level=warning msg="Running modprobe nf_nat failed with message: ``, error: exec: \"modprobe\": executable file not found in $PATH"
time="2018-10-26T13:25:09.920733300Z" level=warning msg="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 DOCKER: iptables failed: iptables -t nat -N DOCKER: iptables v1.6.1: can't initialize iptables table `nat': Permission denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.
 (exit status 3)
time=“2018-10-26T13:25:09.920187300Z”level=info msg=“scheme\”unix\”未注册,回退到默认方案”module=grpc
time=“2018-10-26T13:25:09.920228600Z”level=info msg=“CCresolverRapper:向cc发送新地址:[{unix:///var/run/docker/containerd/docker-containerd.sock 0}]“模块=grpc
time=“2018-10-26T13:25:09.9202500Z”level=info msg=“ClientConn将平衡器切换到\“pick_first\”模块=grpc
time=“2018-10-26T13:25:09.920286200Z”level=info msg=“pickfirstBalancer:HandleSubConnStateChange:0xc420047e60,CONNECTING”模块=grpc
time=“2018-10-26T13:25:09.920480100Z”level=info msg=“pickfirstBalancer:HandleSubConnStateChange:0xc420047e60,READY”模块=grpc
time=“2018-10-26T13:25:09.920501400Z”level=info msg=“装载集装箱:开始。”
time=“2018-10-26T13:25:09.9206666400Z”level=warning msg=“运行modprobe桥br\u netfilter失败,消息:,错误:exec:\“modprobe\”:在$PATH中找不到可执行文件”
time=“2018-10-26T13:25:09.920704800Z”level=warning msg=“运行modprobe nf\u nat失败,消息为:``,错误:exec:\“modprobe\”:在$PATH中找不到可执行文件”
time=“2018-10-26T13:25:09.92073300Z”level=warning msg=“运行modprobe xt\u conntrack失败,消息为:``,错误:exec:\“modprobe\”:在$PATH中找不到可执行文件”
启动守护程序时出错:初始化网络控制器时出错:获取控制器实例时出错:无法创建NAT链DOCKER:iptables失败:iptables-t NAT-N DOCKER:iptables v1.6.1:无法初始化iptables表“NAT”:权限被拒绝(您必须是root)
可能需要升级iptables或内核。
(退出状态3)

典型的Docker容器是在一组受限权限下运行的。即使您是容器中的
root
,也不能修改网络配置,也不能装载文件系统。所以你看到的错误

启动守护程序时出错:初始化网络控制器时出错:获取控制器实例时出错:无法创建NAT链DOCKER:iptables失败:iptables-t NAT-N DOCKER:iptables v1.6.1:无法初始化iptables表“NAT”:权限被拒绝(您必须是root)

…正是由于这一限制而发生的。您可以创建一个 通过使用以下容器创建无限制容器:

docker run --privileged ...
您可能可以使用更细粒度和更高级别的工具
NET\u ADMIN
功能,如:

docker run --cap-add NET_ADMIN ...

只要容器所需的唯一“特殊”特权是网络配置,这将起作用。

假设您不能在Docker映像中安装Docker;这几乎肯定不是正确的解决方案,它本身就很复杂,Docker不鼓励这样做,这会让你对你实际上在和哪个Docker说话感到困惑。你更高层次的目标是什么?通常的答案是“使用主机的Docker”或“使用VM”。Re:@user3423536的评论,请参阅“”