1.拉取私有仓库镜像
[root@master1 ~]# docker pull registry
[root@master1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx v1 546db553f62a About an hour ago 142 MB
docker.io/nginx 1.24.0 6b753f58c54e 13 days ago 142 MB
docker.io/nginx latest 605c77e624dd 22 months ago 141 MB
docker.io/registry latest b8604a3fe854 23 months ago 26.2 MB
docker.io/centos latest 5d0da3dc9764 2 years ago 231 MB
docker.io/java latest d23bdf5b1b1b 6 years ago 643 MB
2.配置私有镜像仓库地址
[root@master1 ~]# vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://10l.mirror.aliyuncs.com"],
"insecure-registries": ["10.10.10.10:5000"]
}
[root@master1 ~]# systemctl daemon-reload
[root@master1 ~]# systemctl restart docker
3.运行私有仓库
[root@master1 /]# mkdir -p /images/registry
[root@master1 /]# docker run -itd -v /images/registry:/var/lib/registry -p 5000:5000 --restart=always --name registry registry
[root@master1 /]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e361860afb1a registry "/entrypoint.sh /e..." 24 minutes ago Up 24 minutes 0.0.0.0:5000->5000/tcp registry
-v:把宿主机的/data/registry目录挂到容器/var/lib/registry目录
-p:映射宿主机5000端口到容器5000端口
--restart=always:容器退出时重启容器
4.查看查看所有镜像
curl http://10.10.10.10:5000/v2/_catalog
5.上传镜像
[root@master1 /]# docker tag nginx:v1 10.10.10.10:5000/nginx:v1
[root@master1 /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
10.10.10.10:5000/nginx v1 546db553f62a About an hour ago 142 MB
nginx v1 546db553f62a About an hour ago 142 MB
docker.io/nginx 1.24.0 6b753f58c54e 13 days ago 142 MB
docker.io/nginx latest 605c77e624dd 22 months ago 141 MB
docker.io/registry latest b8604a3fe854 23 months ago 26.2 MB
docker.io/centos latest 5d0da3dc9764 2 years ago 231 MB
docker.io/java latest d23bdf5b1b1b 6 years ago 643 MB
[root@master1 /]# docker push 10.10.10.10:5000/nginx:v1
The push refers to a repository [10.10.10.10:5000/nginx]
7870e8bfb94a: Pushed
eda786ae8691: Pushed
1b00f878c74c: Pushed
3a24d9d0eea4: Pushed
29f4355fe596: Pushed
07db6b1a102a: Pushed
81dcbae3e695: Pushed
633f5bf471f7: Pushed
v1: digest: sha256:bd0e85735b1c2cb96d37fe75feb545e2066132679b2343e65f4ef7581d60a39c size: 1984
[root@master1 /]# curl http://10.10.10.10:5000/v2/_catalog
{"repositories":["nginx"]}
配置阿里云镜像仓库
镜像仓库地址:https://cr.console.aliyun.com/cn-zhangjiakou/instance/credentials