代理上网环境配置docker私有库
最后更新时间: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=
environment="https_proxy=
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
{"repositories":["kubernetes-dashboard-amd64","pod-infrastructure"]}
上一篇: js制作简单的时钟v1.0
下一篇: Python捉虫记(持续更新)