最後更新時間:2018年12月27日Docker使用代理上網去 pull 各類 images,需要做如下配置:創建目錄: /etc/systemd/system/docker.service.d寫入配置:http-proxy.conf [root@localhost docker.service.d... ...
最後更新時間:2018年12月27日
Docker使用代理上網去 pull 各類 images,需要做如下配置:
創建目錄: /etc/systemd/system/docker.service.d
寫入配置:http-proxy.conf
[root@localhost docker.service.d]# cat http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://192.168.6.130:8000/"
Environment="HTTPS_PROXY=http://192.168.6.130:8000/"
Environment="NO_PROXY=localhost,127.0.0.1,192.168.6.155,192.168.6.156,192.168.6.157,registry"
註意:NO_PROXY需要單個IP寫,如果命令中涉及主機名的需要在這寫主機名,如下麵 docker push 到 registry。
搭建私有庫
創建本地倉庫容器:
docker pull registry
docker run -d -p 5000:5000 --name=registry --restart=always --privileged=true -v /data/registrydata:/tmp/registry registry
修改配置增加 insecure-registries:
[root@localhost ~]# cat /etc/docker/daemon.json
{
"insecure-registries": [
"registry:5000"
]
}
重啟服務
systemctl daemon-reload
systemctl restart docker
添加新tag,測試推送
docker tag docker.io/googlecontainer/kubernetes-dashboard-amd64 registry:5000/kubernetes-dashboard-amd64:v1.5.1
docker push registry:5000/kubernetes-dashboard-amd64
[root@localhost ~]# docker push registry:5000/kubernetes-dashboard-amd64
The push refers to a repository [registry:5000/kubernetes-dashboard-amd64]
25820b2590cc: Pushed
v1.5.1: digest: sha256:b9061ebcf970a0782babd20e6a5570c5cf81dc421d81643657a84210f80092fb size: 529
驗證
[root@localhost ~]# curl -XGET http://registry:5000/v2/_catalog
{"repositories":["kubernetes-dashboard-amd64","pod-infrastructure"]}