0

Context: I am using repo2docker to build images containing experiments, then to push them to a private registry.

I am dockerizing this whole pipeline (cloning the code of the experiment, building the image, pushing it) with docker-compose.

This is what I tried:

FROM ubuntu:latest

RUN apt-get update && apt-get install -y python3-pip python3-dev git apt-transport-https ca-certificates curl software-properties-common

RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
RUN apt-get update && apt-get install docker-ce --yes
RUN service docker start

# more setup

ENTRYPOINT rqworker -c settings image_build_queue

Then I pass the jobs to the rqworker (the rqworker part works well).

But docker doesn't start in my container. Therefore I can't login to the registry and can't build the image.

(Note that I need docker to run, but I don't need to run containers.)

MasterScrat
  • 7,090
  • 14
  • 48
  • 80
  • https://hub.docker.com/_/docker/ – Brian Aug 01 '18 at 18:52
  • Two universal pieces of advice: you can't run Docker inside Docker (you usually need to share the host's Docker socket), and `service` just doesn't work inside Docker. (Neither is actually totally true but things will be much easier if you don't jump through the many hoops required to make either work.) – David Maze Aug 01 '18 at 23:33
  • @DavidMaze "you usually need to share the host's Docker socket" yep that worked! please make your comment an answer. – MasterScrat Aug 02 '18 at 13:46

1 Answers1

0

The solution was to share the host's Docker socket, so the build actually happens on the host.

MasterScrat
  • 7,090
  • 14
  • 48
  • 80