运行我的Dockerfile时,我需要获取依赖项。这是使用go get ./...
完成的。
然而,在执行docker build -t test .
时,它会在go get命令处挂起。
exec go get -v -d
github.com/gorilla/mux(下载) cd .; git clone https://github.com/gorilla/mux /go/src/github.com/gorilla/mux克隆到 ' /go/src/github.com/gorilla/mux' ...致命:无法访问 ' https://github.com/gorilla/mux/':无法解析主机:github.com 包github.com/gorilla/mux:退出状态128
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"]
答案 0 :(得分:0)
我假设你是通过另一台机器上的ssh做的。检查/etc/network/interfaces
中是否有dns服务器。看起来应该是这样的:
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服务器工作是8.8.8.8
和8.8.4.4
,均由Google提供。如果这不能解决您的问题,您应该检查您的互联网连接是否有其他错误配置,但首先尝试这个。