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 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算