3

I'm trying to create a docker image that pulls from a both private and public github repositories. The dockerfile I'm using is

FROM golang:1.4.2-onbuild

ENV GOPATH /go
ENV PATH /go/bin:$PATH

EXPOSE 3000

RUN mkdir -p /go/src/github.com/eddi/api
RUN git clone https://<access token>@github.com/owner/repo.git /go/src/github.com/owner/repo

WORKDIR /go/src/github.com/eddi/api

RUN go get github.com/gin-gonic/gin
RUN go run server.go

But when I run docker build . I get the following error:

cd .; git clone https://github.com/gin-gonic/gin /go/src/github.com/gin-gonic/gin

Cloning into '/go/src/github.com/gin-gonic/gin'...

fatal: unable to access 'https://github.com/gin-gonic/gin/': Could not resolve h ost: github.com

for both private and public repositories. How can I get my dockerfile to behave well with importing libraries?

Yaro
  • 39
  • 4
  • To me that looks more like a network issue (you cannot access github.com) on the Docker host on which you are trying to build that image. – Henrik Sachse Jul 23 '15 at 09:22
  • I checked internet connectivity as suggested in http://stackoverflow.com/questions/17002663/how-to-configure-docker-to-be-able-to-have-internet-access-via-wireless-connecti, and it was able to connect to google. I'm still getting the same errors when I try to build my image, though. – Yaro Jul 23 '15 at 17:10
  • Did you try to use a different DNS server for your docker daemon with 'docker --dns 8.8.8.8' already? – Henrik Sachse Jul 23 '15 at 17:14
  • Yeah, it gave me the same results as running without --dns. – Yaro Jul 23 '15 at 18:20
  • have you tried using a github machine key with read access and using the git@github syntax for cloning? – nkhumphreys Aug 05 '15 at 13:16

2 Answers2

0

First check DNS on your local machine with dig github.com or nslookup github.com.

What is your docker setup? Kitematic or Boot2docker? If it's launching from the helper VM then try running the commands there, which is where it's trying to build, and failing on the lookup. Often the lookup failure just means no route to the internet, since host resolution is the first step in connecting to its IP.

0

For people googling this question.

It is probably boot2docker that for some reason lose network. Just restart it with docker-machine restart default.

fredriksvensson
  • 133
  • 1
  • 3