赞
踩
在使用阿里云服务器部署docker-compose时,需要从GitHub部署下载文件;
使用以下命令下载docker-compose安装包,会出现连接失败的情况,直接ping也是无法ping通的
curl -L https://github.com/docker/compose/releases/download/v2.17.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
国内的运营厂商由于某些特殊原因,连接GitHub会超时,即使连接上也会很慢掉线等,网上查找有些大佬给了解释:
通过修改hosts文件的方法,直接访问 GitHub 的 CDN 节点,从而达到加速的目的。
1.GitHub520
GitHub520是一个开源的GitHub项目,帮助大家访问GitHub,还提供了无需访问GitHub就能获取最新的hosts内容:
https://raw.hellogithub.com/hosts
https://raw.hellogithub.com/hosts.json
2.操作
(1)Linux的hosts文件存储地址是 /etc/hosts
vim /etc/hosts
(2)复制以下内容到hosts文件中(备注,如果失效需要从1中的GitHub获取新的hosts内容)
# GitHub520 Host Start 140.82.114.26 alive.github.com 140.82.112.5 api.github.com 185.199.111.153 assets-cdn.github.com 185.199.110.133 avatars.githubusercontent.com 185.199.110.133 avatars0.githubusercontent.com 185.199.110.133 avatars1.githubusercontent.com 185.199.110.133 avatars2.githubusercontent.com 185.199.110.133 avatars3.githubusercontent.com 185.199.110.133 avatars4.githubusercontent.com 185.199.110.133 avatars5.githubusercontent.com 185.199.110.133 camo.githubusercontent.com 140.82.112.21 central.github.com 185.199.108.133 cloud.githubusercontent.com 140.82.114.9 codeload.github.com 140.82.113.21 collector.github.com 185.199.110.133 desktop.githubusercontent.com 185.199.110.133 favicons.githubusercontent.com 140.82.114.3 gist.github.com 54.231.132.201 github-cloud.s3.amazonaws.com 52.217.159.33 github-com.s3.amazonaws.com 16.182.70.201 github-production-release-asset-2e65be.s3.amazonaws.com 52.217.71.156 github-production-repository-file-5c1aeb.s3.amazonaws.com 52.216.77.12 github-production-user-asset-6210df.s3.amazonaws.com 192.0.66.2 github.blog 140.82.114.3 github.com 140.82.112.17 github.community 185.199.110.154 github.githubassets.com 151.101.1.194 github.global.ssl.fastly.net 185.199.110.153 github.io 185.199.108.133 github.map.fastly.net 185.199.110.153 githubstatus.com 140.82.114.26 live.github.com 185.199.108.133 media.githubusercontent.com 185.199.110.133 objects.githubusercontent.com 13.107.42.16 pipelines.actions.githubusercontent.com 185.199.108.133 raw.githubusercontent.com 185.199.108.133 user-images.githubusercontent.com 13.107.213.40 vscode.dev 140.82.112.21 education.github.com # Update time: 2023-12-09T12:05:19+08:00 # Update url: https://raw.hellogithub.com/hosts # Star me: https://github.com/521xueweihan/GitHub520 # GitHub520 Host End
(3)激活生效
一般情况是立即生效,未生效可尝试使用以下命令
sudo nscd restart
,
如报错则须安装:sudo apt install nscd
或 sudo /etc/init.d/nscd restart
均无效尝试重启机器
3.备注
GitHub520 还提供了SwitchHosts管理工具自动更新的方式,包括windows系统,安卓系统,ios系统等系统的更改方法
参考:
GitHub520: 让你“爱”上 GitHub,解决访问时图裂、加载慢的问题。(无需安装) github地址:https://github.com/521xueweihan/GitHub520
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。