Docker入门-使用registry镜像创建私有仓库

Docker搭建本地私有仓库

本篇主要介绍

  • 使用registry镜像创建私有仓库并上传镜像

使用registry镜像创建私有仓库

默认情况下,仓库会被创建在容器的/var/lib/registry目录下。可以通过-v参数来将镜像文件存放在本地的指定路径。例如下面的例子将上传的镜像放到/u01/learn/docker/registry/目录。此时,在本地将启动一个私有仓库服务,监听端口为5000.

docker run -d -p 5000:5000 -v /u01/learn/docker/registry/:/var/lib/registry registry:2

管理私有仓库

  1. 编辑/etc/docker/daemon.json,在其中添加insecure-registries标签,属性值为搭建的仓库地址
  2. 推送镜像docker push 192.168.15.79:5000/halm-front:1.0
  3. 重启docker,重启registry容器
[root@localhost ~]# cat /etc/docker/daemon.json 
{
    
    
  "registry-mirrors": ["https://dca8zh55.mirror.aliyuncs.com"],
  "insecure-registries": ["192.168.15.79:5000"]

}
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker
[root@localhost ~]# docker push 192.168.15.79:5000/halm-front:1.0
[root@localhost ~]# docker run -d -p 5000:5000 -v /u01/learn/docker/registry/:/var/lib/registry registry:2
 [root@localhost ~]# curl http://localhost:5000/v2/_catalog
{
    
    "repositories":["halm-front"]}

猜你喜欢

转载自blog.csdn.net/weixin_43169156/article/details/115087387