Docker编译出现:temporary error (try again later)

xiaohai 2020-08-19 16:59:30 12545人围观 标签: Docker 
简介Docker编译镜像出现:fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.12/main: temporary error (try again later) WARNING: Ignoring APKINDEX.2c4ac24e.tar.gz: No such file or directory问题

通过alpine构建其他的镜像报错,报临时文件不可用,但是,通过浏览器是直接可以下载到tar包的。错误如下:

fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.12/main: temporary error (try again later)
WARNING: Ignoring APKINDEX.2c4ac24e.tar.gz: No such file or directory
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
2 errors; 14 distinct packages available
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.12/community: temporary error (try again later)
WARNING: Ignoring APKINDEX.40a3604f.tar.gz: No such file or directory

在网上查找了一翻,有些说重启docker服务就可以,有些说需要设置DNS,但是这些都试过后还是不行,最终通过:基于alpine构建镜像报错temporary error (try again later)?该文章找到可以用的方法了。就是在我们build命令后增加–network=host即可,如:

docker build -t go-proxy:0.0.1 . --network=host