安装docker-compose异常: Failed to connect to github-production-release-XX-.s3.amazonaws.com port 443:连接超

时间:2022-02-20 18:13:50

根据docker官网提供的docker-compose安装教程,在ubuntu机器上安装最新的docker-compose,结果出现如下异常:

 Failed to connect to github-production-release-asset-2e65be.s3.amazonaws.com port 443: 连接超时


安装过程如下:

$ sudo -i
root@far:~# curl -L https://github.com/docker/compose/releases/download/1.14.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   617    0   617    0     0    330      0 --:--:--  0:00:01 --:--:--   330
  0     0    0     0    0     0      0      0 --:--:--  0:02:12 --:--:--     0curl: (7) Failed to connect to github-production-release-asset-2e65be.s3.amazonaws.com port 443: 连接超时


问题原因:

该地址(github-production-release-asset-2e65be.s3.amazonaws.com) 需要的一些下载的访问被 国内屏蔽了,需要设置下hosts文件,使用香港的服务器。


解决办法:

在hosts文件中,加入这一行:

219.76.4.4 github-cloud.s3.amazonaws.com

修改了hosts文件后,按照docker官网提供的docker-compose安装教程,重新安装,ok。

sudo -i
root@far:~# curl -L https://github.com/docker/compose/releases/download/1.15.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   617    0   617    0     0    327      0 --:--:--  0:00:01 --:--:--   327
100 8650k  100 8650k    0     0  18372      0  0:08:02  0:08:02 --:--:-- 16417
root@far:~# exit


对比了下美国、香港 ping的速度,发现美国的服务器延迟比较大

$ ping github-cloud.s3.amazonaws.com
PING github-cloud.s3.amazonaws.com (219.76.4.4) 56(84) bytes of data.
64 bytes from github-cloud.s3.amazonaws.com (219.76.4.4): icmp_seq=1 ttl=50 time=54.4 ms
64 bytes from github-cloud.s3.amazonaws.com (219.76.4.4): icmp_seq=2 ttl=51 time=90.9 ms
64 bytes from github-cloud.s3.amazonaws.com (219.76.4.4): icmp_seq=3 ttl=51 time=69.8 ms
64 bytes from github-cloud.s3.amazonaws.com (219.76.4.4): icmp_seq=4 ttl=50 time=38.5 ms

$ ping github-cloud.s3.amazonaws.com
PING s3-1-w.amazonaws.com (54.231.49.64) 56(84) bytes of data.
64 bytes from s3-1-w.amazonaws.com (54.231.49.64): icmp_seq=1 ttl=41 time=253 ms
64 bytes from s3-1-w.amazonaws.com (54.231.49.64): icmp_seq=3 ttl=41 time=253 ms
64 bytes from s3-1-w.amazonaws.com (54.231.49.64): icmp_seq=4 ttl=41 time=254 ms
64 bytes from s3-1-w.amazonaws.com (54.231.49.64): icmp_seq=5 ttl=41 time=253 ms
64 bytes from s3-1-w.amazonaws.com (54.231.49.64): icmp_seq=6 ttl=41 time=253 ms


参考:

http://www.mobibrw.com/2017/6047/comment-page-1

https://docs.docker.com/compose/install/#alternative-install-options