douke1905 2016-08-25 19:20
浏览 983

Docker:无法解析主机:github.com-进行获取。

When running my Dockerfile I need to grab dependencies. This is done using go get ./....

However when doing docker build -t test . it hangs at the go get command.

here is the error message

exec go get -v -d

github.com/gorilla/mux (download) cd .; git clone https://github.com/gorilla/mux /go/src/github.com/gorilla/mux Cloning into '/go/src/github.com/gorilla/mux'... fatal: unable to access 'https://github.com/gorilla/mux/': Could not resolve host: github.com package github.com/gorilla/mux: exit status 128

here is the dockerfile

FROM golang

# Create a directory inside the container to store all our application and then make it the working directory.
RUN mkdir -p /go/src/example-app
WORKDIR /go/src/example-app

# Copy the example-app directory (where the Dockerfile lives) into the container.
COPY . /go/src/example-app

# Download and install any required third party dependencies into the container.
RUN go-wrapper download
RUN go-wrapper install
RUN go get ./...

# Set the PORT environment variable inside the container
ENV PORT 8080

# Expose port 8080 to the host so we can access our application
EXPOSE 8080

# Now tell Docker what command to run when the container starts
CMD ["go-wrapper", "run"]
  • 写回答

1条回答

  • dongming4994 2016-08-25 19:34
    关注

    I assume you're doing that via ssh on another machine. Check if it has a dns server in your /etc/network/interfaces. It should look somehow like this:

    iface eth0 inet static
        address 192.168.2.9
        gateway 192.168.2.1
        netmask 255.255.255.0
        broadcast 192.168.2.255
        dns-nameservers 192.168.2.1 8.8.4.4
    

    DNS servers that "always" work are 8.8.8.8 and 8.8.4.4, both provided by Google. If that doesn't resolve your problem, you should check your internet connection for other misconfigurations, but first try this.

    评论

报告相同问题?

悬赏问题

  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?