最近在折腾docker。在公司的机子上,由于是多条线路,而且带宽较高,下载docker还没什么问题。回到家后,只有2M的ADSL,在安装docker时,总是下载不了。

sudo apt-get install docker-ce

错误 https://download.docker.com/linux/ubuntu/ trusty/stable docker-ce amd64 17.03.1~ce-0~ubuntu-trusty
  Operation too slow. Less than 10 bytes/sec transferred the last 120 seconds
下载 96.2 kB,耗时 2分 39秒 (602 B/s)
E: 无法下载 https://download.docker.com/linux/ubuntu/dists/trusty/pool/stable/amd64/docker-ce_17.03.1~ce-0~ubuntu-trusty_amd64.deb  Operation too slow. Less than 10 bytes/sec transferred the last 120 seconds

错误 https://download.docker.com/linux/ubuntu/ trusty/stable docker-ce amd64 17.03.1~ce-0~ubuntu-trusty
  gnutls_handshake() failed: A TLS packet with unexpected length was received.
E: 无法下载 https://download.docker.com/linux/ubuntu/dists/trusty/pool/stable/amd64/docker-ce_17.03.1~ce-0~ubuntu-trusty_amd64.deb  gnutls_handshake() failed: A TLS packet with unexpected length was received.

试了好多次,都不成功。不得不请出我的***。

  shadownsocks是socks5代理,而apt-get是走http的,没法直接用。需要找个软件将socks5转换为http代理。我的要求是,这个软件比较小巧。在我不用的时候,可以不管它,毕竟我的源是163的,平时都不走代理。google了一下,发现proxychains比较合适,配置简单,在需要时,只需要加个前缀,不需要时,像平常一样运行程序即可。安装proxychains并修改配置。

sudo apt-get install proxychains
sudo vi /etc/proxychains.conf 

我的***在本地的1080端口,所以配置如下:

# proxychains.conf  VER 3.1
#
#        HTTP, SOCKS4, SOCKS5 tunneling proxifier with DNS.
#    

# The option below identifies how the ProxyList is treated.
# only one option should be uncommented at time,
# otherwise the last appearing option will be accepted
#
#dynamic_chain
#
# Dynamic - Each connection will be done via chained proxies
# all proxies chained in the order as they appear in the list
# at least one proxy must be online to play in chain
# (dead proxies are skipped)
# otherwise EINTR is returned to the app
#
strict_chain
#
# Strict - Each connection will be done via chained proxies
# all proxies chained in the order as they appear in the list
# all proxies must be online to play in chain
# otherwise EINTR is returned to the app
#
#random_chain
#
# Random - Each connection will be done via random proxy
# (or proxy chain, see  chain_len) from the list.
# this option is good to test your IDS :)

# Make sense only if random_chain
#chain_len = 2

# Quiet mode (no output from library)
#quiet_mode

# Proxy DNS requests - no leak for DNS data
proxy_dns 

# Some timeouts in milliseconds
tcp_read_time_out 15000
tcp_connect_time_out 8000

# ProxyList format
#       type  host  port [user pass]
#       (values separated by 'tab' or 'blank')
#
#
#        Examples:
#
#                socks5    192.168.67.78    1080    lamer    secret
#        http    192.168.89.3    8080    justu    hidden
#         socks4    192.168.1.49    1080
#            http    192.168.39.93    8080    
#        
#
#       proxy types: http, socks4, socks5
#        ( auth types supported: "basic"-http  "user/pass"-socks )
#
[ProxyList]
# add proxy here ...
# meanwile
# defaults set to "tor"
# socks4     127.0.0.1 9050
socks5 127.0.0.1 1080
View Code

主要把最后一行改一下,其他配置默认

# socks4     127.0.0.1 9050
socks5 127.0.0.1 1080

现在测试下代理是否成功:

$ curl ip.gs
Current IP / 当前 IP: xxx.xxx.xxx.xxx
ISP / 运营商:  ChinaTelecom
City / 城市: Guangzhou Guangdong
Country / 国家: China
Please join Telegram group https://t.me/sbfans if you have any issues. / 如有问题,请加入 Telegram 群 https://t.me/sbfans 

  /\_/\
=( °w° )=
  )   (  //
 (__ __)//

$ proxychians curl ip.gs
ProxyChains-3.1 (http://proxychains.sf.net)
|DNS-request| ip.gs 
|S-chain|-<>-127.0.0.1:1080-<><>-4.2.2.2:53-<><>-OK
|DNS-response| ip.gs is 103.192.224.224
|S-chain|-<>-127.0.0.1:1080-<><>-103.192.224.224:80-<><>-OK
Current IP / 当前 IP: 103.192.224.17
ISP / 运营商:  xtom.com
City / 城市:  Hong Kong
Country / 国家: China
Please join Telegram group https://t.me/sbfans if you have any issues. / 如有问题,请加入 Telegram 群 https://t.me/sbfans 

  /\_/\
=( °w° )=
  )   (  //
 (__ __)//

可以看到,在使用proxychains后,运营商是不一样的。

  现在使用proxychains安装docker:

$ sudo proxychains apt-get install docker-ce
ProxyChains-3.1 (http://proxychains.sf.net)
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
将会安装下列额外的软件包:
  aufs-tools cgroup-lite
下列【新】软件包将被安装:
  aufs-tools cgroup-lite docker-ce
升级了 0 个软件包,新安装了 3 个软件包,要卸载 0 个软件包,有 227 个软件包未被升级。
需要下载 19.1 MB/19.2 MB 的软件包。
解压缩后会消耗掉 88.9 MB 的额外空间。
您希望继续执行吗? [Y/n] y
0% [执行中]|DNS-request| download.docker.com 
|S-chain|-<>-127.0.0.1:1080-<><>-4.2.2.2:53-<><>-OK
0% [执行中]|DNS-response| download.docker.com is 54.230.159.116
0% [执行中]|S-chain|-<>-127.0.0.1:1080-<><>-54.230.159.116:443-<><>-OK
获取:1 https://download.docker.com/linux/ubuntu/ trusty/stable docker-ce amd64 17.03.1~ce-0~ubuntu-trusty [19.1 MB]
下载 19.1 MB,耗时 1分 21秒 (234 kB/s)

很顺利就安装完成。

posted on 2017-05-05 22:34  coding my life  阅读(13)  评论(0)    收藏  举报