一、使用自己的私库
1、安装register私库
docker pull registry
运行
docker run -d -v /data/registry:/var/lib/registry -p 5000:5000 --name registry registry:2
参数-v /data/registry:/var/lib/registry,挂载目录
2、拉取需要的镜像
docker pull hello-world
3、打包tag镜像,并推送
#打包
docker tag hello-world localhost:5000/hello-world
#推送
docker push localhost:5000/hello-world
4、查看私库
http://localhost:5000/v2/_catalog
5、客户端先配置私库,不然会报https协议问题,如果是云服务需要开放5000端口
编辑配置
#修改
vim /etc/docker/daemon.json
#添加参数
"insecure-registries": ["localhost:5000"]
#重启加载配置文件
systemctl daemon-reload
#重启docker
systemctl restart docker
6、拉取镜像
docker pull localhost:5000/hello-world
二、镜像源拉取镜像超时问题
1、由于xx限制很多国内镜像使用不了
修改 /etc/docker/daemon.json配置文件,执行
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors":[
"https://docker.m.daocloud.io",
"https://docker.nju.edu.cn",
"https://docker.mirrors.sjtug.sjtu.edu.cn",
"https://docker.mirrors.ustc.edu.cn",
"https://mirror.iscas.ac.cn",
"https://docker.rainbond.cc"
],
"insecure-registries": ["116.205.245.23:5000"]
}
EOF
如果还是不行,就某度找找可用的镜像源,更替
有些可以直接拉取,但是使用search不行