Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
407 views
in Technique[技术] by (71.8m points)

debian - How to install docker in docker container?

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

The golang Dockerfile is official, it bases on the

Debian GNU/Linux 8 (jessie)

So I wrote down this Dockerfile by checking the install steps from Docker Install Tutor(Debian)

But the output is

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'.

How to solve this problem? I want to establish docker containers in the host docker container.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

  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 ...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...