docker 私有hub搭建及使用


1. 下载registry镜像(该主机必须已安装docker)

docker pull registry:latest

2. 创建数据目录

   D:\soft\docker\registry\data  

3. 运行docker

docker run -d -p 5000:5000 -v D:/soft/docker/registry/data:/opt/docker-image -e SQLALCHEMY_INDEX_DATABASE=sqlite:opt/docker-image/docker-registry.db -e STORAGE_PATH=/opt/docker-image registry

        参数详解

        -p 5000:5000    #暴露5000端口

        -v D:/soft/docker/registry/data:/opt/docker-image

#挂载目录,将docker镜像数据持久化

        -e SQLALCHEMY_INDEX_DATABASE=sqlite:opt/docker-image/docker-registry.db     #设置仓库数据库文件

        -e STORAGE_PATH=/opt/docker-image    #设置仓库数据存储位置

         registry:latest #仓库名和最新版本号

4. docker中镜像的命名规则

     dockerhub.test.com:5000/study/api_msyql:1.0

这是一个完整的image名称,下面说下各部分的作用

dockerhub.test.com:5000:

     image所在服务器地,如果是官方的hub部分忽略

study:namespace,命名空间,或者说成是你镜像的一个分类

api_msyql:镜像的具体名字

1.0 :image的版本号

5. push镜像到私有hub

      docker tag  imageid   dockerhub.test.com:5000/study/api_msyql:1.0

     docker push dockerhub.test.com:5000/study/api_msyql:1.0

6. Pull镜像到本地

     docker pull dockerhub.test.com:5000/study/api_msyql:1.0

7. 查询hub中镜像

       查询所有镜像 :  http://dockerhub.test.com:5000/v2/_catalog

Guess you like

Origin blog.csdn.net/fish_study_csdn/article/details/119699227