首先需要拥有shadowsocks代理服务器
下面安装代理上网利器
CentOS: sudo yum install python-pip sudo pip install shadowsocks
配置
找个地方放shadowsocks的配置文件,一般放到 /etc下面:
sudo vi /etc/shadowsocks.json
然后在shadowsocks.json里面添加配置信息,如:
{ "server":"my_server_ip", "local_address": "$ip", "local_port":1080, "server_port":my_server_port, "password":"my_password", "timeout":300, "method":"aes-256-cfb" }
my_server_ip改为自己的服务器IP
my_server_port改为自己的服务器端口
my_server_password改为自己的密码
method的值改为自己的加密方式,一般是aes-256-cfb或者rc4-md5
local_address改为自己的服务器这样权限允许的服务器都可以使用此代理
开机自启
以下使用Systemd来实现shadowsocks开机自启。
sudo vim /etc/systemd/system/shadowsocks.service
在里面填写如下内容:
[Unit] Description=Shadowsocks Client Service After=network.target [Service] Type=simple User=root ExecStart=/usr/bin/sslocal -c /etc/shadowsocks.json [Install] WantedBy=multi-user.target
设置开机启动
systemctl enable shadowsocks systemctl start shadowsocks
配置docker代理设置
vi /usr/lib/systemd/system/docker.service ''' [Service] Type=notify # the default is not to use systemd for cgroups because the delegate issues still # exists and systemd currently does not support the cgroup feature set required # for containers run by docker Environment="HTTPS_PROXY=socks5://$ip:1080" Environment="NO_PROXY=127.0.0.0/8,192.168.0.0/16" ''' systemctl daemon-reload systemctl reload docker
这样就可以无碍使用因为某些不能说明的原因无法访问的镜像了