如何在 docker 容器中安装 docker? [英] How to install docker in docker container?

查看:258
本文介绍了如何在 docker 容器中安装 docker?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的 Dockerfile:

This is my Dockerfile:

FROM golang
# RUN cat /etc/*release
RUN apt-get update
RUN apt-get -y install apt-transport-https ca-certificates curl gnupg2 software-properties-common
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"

RUN apt-get update
RUN apt-get -y install docker-ce
RUN docker run hello-world

golang Dockerfile 是官方的,它基于

The golang Dockerfile is official, it bases on the

Debian GNU/Linux 8 (jessie)

所以我通过检查 Docker Install Tutor(Debian)

但是输出是

Step 8/8 : RUN docker run hello-world
 ---> Running in b183b8cc5d10
docker: Cannot connect to the Docker daemon at 
unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.

如何解决这个问题?我想在宿主机docker容器中建立docker容器.

推荐答案

我在尝试在 Bamboo Server 映像中安装 Docker 时遇到了类似的问题.要解决这个问题:

I had a similar problem trying to install Docker inside a Bamboo Server image. To solve this:

  1. 首先从您的 Dockerfile
  2. 中删除以下行:RUN docker run hello-world
  3. 最简单的方法是公开 Docker 套接字,通过使用 -v 标志绑定挂载它或使用 Docker Compose 挂载卷:
  1. first remove the line: RUN docker run hello-world from your Dockerfile
  2. The simplest way is to just expose the Docker socket, by bind-mounting it with the -v flag or mounting a volume using Docker Compose:

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

这篇关于如何在 docker 容器中安装 docker?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆