代理
关于http代理服务器的搭建,如果有外(国)网机器,直接用squid建就行了 使用Squid3搭建Docker镜像下载代理 。
如果已有shadowsocks的代理,可以用privoxy转成http代理服务器。
http://nknu.net/proxy-configuration-for-docker-on-centos-7/
1
2
3
4
5
6
Edit /etc/sysconfig/docker and add the following lines:
HTTP_PROXY='http://user:password@proxy-host:proxy-port'
HTTPS_PROXY='http://user:password@proxy-host:proxy-port'
For those settings to be taken into account, you’ll need to restart your docker daemon:
# systemctl restart docker
https://docs.docker.com/engine/admin/systemd/#http-proxy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@k8s docker.service.d]# pwd
/etc/systemd/system/docker.service.d
[root@k8s docker.service.d]# cat http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:8118/" "NO_PROXY=localhost,127.0.0.1"
查看配置的环境变量是否生效
$ sudo systemctl daemon-reload
$ sudo service docker start
$ sudo systemctl show --property Environment docker
配置代理后下载google容器杠杠的
[root@k8s docker-multinode]# docker pull gcr.io/google_containers/etcd-amd64:3.0.4
如果是自己编译的docker,自启动脚本配置可以参考:https://github.com/docker/docker/blob/master/contrib/init/systemd/docker.socket
导入导出
https://tuhrig.de/difference-between-save-and-export-in-docker/
对于已经通过代理下载的docker,可以通过导入导出到另外的机器。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
[root@k8s ~]# docker save `docker images | grep -v TAG | awk '{print $1":"$2}'` >k8s.tar
[root@k8s data]# docker load <k8s.tar
0341ae9b0004: Loading layer [==================================================>] 89.1 MB/89.1 MB
Loaded image: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.5.0
011b303988d2: Loading layer [==================================================>] 5.05 MB/5.05 MB
5f70bf18a086: Loading layer [==================================================>] 1.024 kB/1.024 kB
596242791254: Loading layer [==================================================>] 792.1 kB/792.1 kB
4e504f64df23: Loading layer [==================================================>] 5.29 MB/5.29 MB
2897536d1f1f: Loading layer [==================================================>] 3.584 kB/3.584 kB
ae11e34e71e6: Loading layer [==================================================>] 10.75 kB/10.75 kB
81620de5436f: Loading layer [==================================================>] 2.56 kB/2.56 kB
77cb0f2fbaed: Loading layer [==================================================>] 50.33 MB/50.33 MB
Loaded image: gcr.io/google_containers/kube-addon-manager-amd64:v6.1
9007f5987db3: Loading layer [==================================================>] 5.05 MB/5.05 MB
5f70bf18a086: Loading layer [==================================================>] 1.024 kB/1.024 kB
d41159f2130e: Loading layer [==================================================>] 9.201 MB/9.201 MB
Loaded image: gcr.io/google_containers/dnsmasq-metrics-amd64:1.0
2c84284818d1: Loading layer [==================================================>] 1.312 MB/1.312 MB
5f70bf18a086: Loading layer [==================================================>] 1.024 kB/1.024 kB
5e47621858b3: Loading layer [==================================================>] 38.51 MB/38.51 MB
Loaded image: gcr.io/google_containers/etcd-amd64:3.0.4
b6ca02dfe5e6: Loading layer [==================================================>] 128.9 MB/128.9 MB
c2c974a0ae12: Loading layer [==================================================>] 231.6 MB/231.6 MB
88e4c6b7e766: Loading layer [==================================================>] 25.09 kB/25.09 kB
96257390754d: Loading layer [==================================================>] 10.75 kB/10.75 kB
36bd77066b3a: Loading layer [==================================================>] 7.68 kB/7.68 kB
6e833518b289: Loading layer [==================================================>] 28.16 kB/28.16 kB
88d2c1399894: Loading layer [==================================================>] 11.78 kB/11.78 kB
b857f858f4ad: Loading layer [==================================================>] 46.08 kB/46.08 kB
13da16246a77: Loading layer [==================================================>] 56.58 MB/56.58 MB
98a8cc89f2d0: Loading layer [==================================================>] 4.608 kB/4.608 kB
1b7eeaac3364: Loading layer [==================================================>] 5.12 kB/5.12 kB
c85758bfcfdf: Loading layer [==================================================>] 153.9 MB/153.9 MB
Loaded image: gcr.io/google_containers/hyperkube-amd64:v1.5.2
3fc666989c1d: Loading layer [==================================================>] 5.046 MB/5.046 MB
5f70bf18a086: Loading layer [==================================================>] 1.024 kB/1.024 kB
9eed5e14d7fb: Loading layer [==================================================>] 348.7 kB/348.7 kB
00dc4ffe8624: Loading layer [==================================================>] 2.56 kB/2.56 kB
Loaded image: gcr.io/google_containers/kube-dnsmasq-amd64:1.4
8ac8bfaff55a: Loading layer [==================================================>] 1.293 MB/1.293 MB
5f70bf18a086: Loading layer [==================================================>] 1.024 kB/1.024 kB
dc978cfc3e09: Loading layer [==================================================>] 7.279 MB/7.279 MB
99740866972b: Loading layer [==================================================>] 7.168 kB/7.168 kB
Loaded image: gcr.io/google_containers/exechealthz-amd64:1.2
5f70bf18a086: Loading layer [==================================================>] 1.024 kB/1.024 kB
41ff149e94f2: Loading layer [==================================================>] 748.5 kB/748.5 kB
Loaded image: gcr.io/google_containers/pause-amd64:3.0
b79219965469: Loading layer [==================================================>] 45.91 MB/45.91 MB
Loaded image: gcr.io/google_containers/kubedns-amd64:1.9
–END