gpt4 book ai didi

docker - docker 内的 docker ,发布HTTP错误

转载 作者:行者123 更新时间:2023-12-02 21:29:11 26 4
gpt4 key购买 nike

我正在尝试在docker中运行docker。唯一的目的是实验性的,我绝不尝试实现任何功能,我只想检查docker从另一个docker运行时的性能。

我通过Mac上的boot2docker启动docker,然后启动一个简单的ubuntu镜像。

$ docker run -t -i ubuntu /bin/bash

然后我继续安装docker和python。
root@aa9263c874e4: apt-get update
root@aa9263c874e4: apt-get install -y docker.io python2.7

它能够连接到Internet,因为它执行此apt-get。当我尝试从Docker内部启动Docker实例时,出现以下错误:
root@aa9263c874e4: sudo docker run -t -i ubuntu /bin/bash
2015/01/09 08:59:09 Post http:///var/run/docker.sock/v1.12/containers/create: dial unix /var/run/docker.sock: no such file or directory

知道我错过了什么吗?我收到一个发布错误似乎很奇怪,因为它似乎能够通过apt-get之前连接到互联网。

最佳答案

我之前在howto run a Docker container inside Docker上回答了类似的问题。

To run docker inside docker is definitely possible. The main thing is that you run the outer container with extra privileges (starting with --privileged=true) and then install docker in that container.

Check this blog post for more info: Docker-in-Docker.

An excellent use case for this is described in this entry. The blog describes how to build docker containers within a Jenkins docker container.


因此,我相信您的 POST问题与连接到互联网无关,因为该容器正试图与Docker套接字通信。要解决此问题,只需在启动外部容器时在其上添加 --privileged=true标志,如下所示:
docker run --privileged=true ...

关于docker - docker 内的 docker ,发布HTTP错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27863471/

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