3
votes

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?

2
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.0x7d7b
I checked internet connectivity as suggested in stackoverflow.com/questions/17002663/…, and it was able to connect to google. I'm still getting the same errors when I try to build my image, though.Yaro
Did you try to use a different DNS server for your docker daemon with 'docker --dns 8.8.8.8' already?0x7d7b
Yeah, it gave me the same results as running without --dns.Yaro
have you tried using a github machine key with read access and using the git@github syntax for cloning?nkhumphreys

2 Answers

0
votes

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
votes

For people googling this question.

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