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?
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.
For people googling this question.
It is probably boot2docker that for some reason lose network. Just restart it with docker-machine restart default.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.