我正在尝试创建一个来自私有和公共github存储库的docker镜像。我正在使用的dockerfile是
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
但是当我运行docker build时。我收到以下错误:
cd。; git clone https://github.com/gin-gonic/gin /go/src/github.com/gin-gonic/gin
克隆到'/go/src/github.com/gin-gonic/gin'...
致命:无法访问“https://github.com/gin-gonic/gin/”:无法解决问题:github.com
用于私有和公共存储库。如何让我的dockerfile在导入库时表现良好?
答案 0 :(得分:0)
首先使用dig github.com
或nslookup github.com
检查本地计算机上的DNS。
您的码头设置是什么? Kitematic还是Boot2docker?如果它从帮助器VM启动,那么尝试在那里运行命令,这是它正在尝试构建的地方,并且在查找时失败。查找失败通常意味着没有到互联网的路由,因为主机解析是连接到其IP的第一步。
答案 1 :(得分:0)
对于谷歌搜索这个问题。
可能是boot2docker由于某种原因失去了网络。只需使用docker-machine restart default重新启动它。