创建私有仓库
下载registry镜像
docker pull registry
指定镜像仓库地址
vim /etc/docker/daemon.json
{
"insecure-registries": ["192.168.159.11:5000"], '//添加此段,本机IP地址'
"registry-mirrors": ["https://q0kfjn11.mirror.aliyuncs.com"]
}
systemctl restart docker.service
创建registry容器并开放端口
docker run -d -p 5000:5000 -v /data/registry:/tmp/registry registry
'//-p指定端口,一内一外;-v表示挂载,前者是宿主机,后者是容器'
测试 镜像打标签后上传
docker tag nginx:latest 192.168.159.105:5000/nginx
docker push 192.168.159.105:5000/nginx
查看私有仓库列表查看是否上传成功
curl -XGET http://192.168.159.105:5000/v2/_catalog
'//若成功会返回以下值'
{"repositories":["nginx"]}
从私有仓库下载镜像
[root@localhost ~]# docker rmi 192.168.159.105:5000/nginx:latest
Untagged: 192.168.159.105:5000/nginx:latest
Untagged: 192.168.159.105:5000/nginx@sha256:ee89b00528ff4f02f2405e4ee221743ebc3f8e8dd0bfd5c4c20a2fa2aaa7ede3
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 605c77e624dd 3 weeks ago 141MB
registry latest b8604a3fe854 2 months ago 26.2MB
[root@localhost ~]# docker pull 192.168.159.105:5000/nginx
Using default tag: latest
latest: Pulling from nginx
Digest: sha256:ee89b00528ff4f02f2405e4ee221743ebc3f8e8dd0bfd5c4c20a2fa2aaa7ede3
Status: Downloaded newer image for 192.168.159.105:5000/nginx:latest
192.168.159.105:5000/nginx:latest
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.159.105:5000/nginx latest 605c77e624dd 3 weeks ago 141MB
nginx latest 605c77e624dd 3 weeks ago 141MB
registry latest b8604a3fe854 2 months ago 26.2MB