①下载 registry 镜像
docker pull registry
②指定镜像仓库地址
vim /etc/docker/daemon.json
{
"insecure-registries": ["192.168.78.11:5000"], '//添加此段,本机IP地址'
"registry-mirrors": ["https://********.mirror.aliyuncs.com"]
}
systemctl restart docker.service
③创建 registry 容器并开放端口
docker create -it registry /bin/bash
docker start b8e64eefc883
docker run -d -p 5000:5000 -v /data/registry:/tmp/registry registry
'//-p指定端口,一内一外;-v表示挂载,前者是宿主机,后者是容器'
④给镜像打标签后上传
docker tag nginx:latest 192.168.78.11:5000/nginx
docker push 192.168.78.11:5000/nginx
⑤获取私有仓库列表查看是否上传成功
curl -XGET http://192.168.78.11:5000/v2/_catalog
'//若成功会返回以下值'
{"repositories":["nginx"]}
⑥从私有仓库下载镜像
docker images
docker rmi 192.168.78.11:5000/nginx:latest nginx:latest
docker images
docker pull 192.168.78.11:5000/sshd
docker images