1、问题
构建fluentbit-operator工程manager模块docker镜像时报如下错误:
由于github.com被墙了需要在Dockerfile里面配置go proxy(加上第四行、第五行)。
注意:也可以配置GOPROXY=https://goproxy.io,但是推荐使用七牛云的“goproxy.cn”,因为“goproxy.io”也不一定可用。对于golang 1.13及以上版本,可直接如下这样:
本来以为配置上go proxy后问题就解决了,没想到还是报错,错误如下:
2、解决方案
build的时候走到下载mod包会报错:go: github.com/fsnotify/fsnotify@v1.4.9: Get "https://goproxy.cn/github.com/fsnotify/fsnotify/@v/v1.4.9.mod": dial tcp: lookup goproxy.cn on 114.114.114.114:53: read udp 172.17.0.3:57936->114.114.114.114:53: i/o timeout。
开始以为代理问题,然后又怀疑DNS问题,最终排除了这两个部分,于是猜测容器里是不是不通外网?
还真是如此。
因为之前的build指令没有特殊指定网络,所以修正指令后如下:
可以正常构建出镜像,注意即使加了--network host也需要给Dockerfile配置上go proxy,不然还会一直卡在go mod download这步。