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"]

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.