zoukankan      html  css  js  c++  java
  • docker 创建私有镜像之 registry

    一、下载 registry 镜像

    [root@localhost ~]# docker pull registry
    Using default tag: latest
    latest: Pulling from library/registry
    c87736221ed0: Pull complete 
    1cc8e0bb44df: Pull complete 
    54d33bcb37f5: Pull complete 
    e8afc091c171: Pull complete 
    b4541f6d3db6: Pull complete 
    Digest: sha256:f87f2b82b4873e0651f928dcde9556008314543bd863b3f7e5e8d03b04e117f7
    Status: Downloaded newer image for registry:latest

    二、创建镜像存储目录

    [root@localhost ~]# mkdir /data/registry

    三、创建镜像容器

    [root@localhost ~]# docker run -itd -v /data/registry:/var/lib/registry -p 80:5000 --restart=always --name registry registry
    e630985b09af4dedcf81a8dcb80202e591fefefc0a86e8328be70ce0643ab399
    #检查容器是否创建成功
    [root@localhost ~]# docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
    e630985b09af        registry            "/entrypoint.sh /etc…"   23 seconds ago      Up 22 seconds       0.0.0.0:80->5000/tcp   registry
    #检查容器运行是否正常,如下显示说明运行正常
    [root@localhost ~]# curl http://127.0.0.1/v2/_catalog     
    {"repositories":[]}

    四、修改daemon.json文件,修改为如下内容

    [root@localhost ~]# vim /etc/docker/daemon.json 
    {
    "registry-mirrors": ["https://wixr8yss.mirror.aliyuncs.com"],
    "insecure-registries":["10.10.0.110:80"],
    "bip":"172.31.0.1/16"
    }

    五、重启docker

    [root@localhost ~]# systemctl restart docker

    六、测试

    #从官方pull busybox 镜像
    [root@localhost ~]# docker pull busybox
    Using default tag: latest
    latest: Pulling from library/busybox
    53071b97a884: Pull complete 
    Digest: sha256:4b6ad3a68d34da29bf7c8ccb5d355ba8b4babcad1f99798204e7abb43e54ee3d
    Status: Downloaded newer image for busybox:latest
    #查看当前镜像
    [root@localhost ~]# docker image ls
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    busybox             latest              64f5d945efcc        5 days ago          1.2MB
    registry            latest              f32a97de94e1        2 months ago        25.8MB
    #为镜像打tag
    [root@localhost ~]# docker tag busybox:latest 10.10.0.110:80/busybox:v1
    #查看tag 是否标记成功
    [root@localhost ~]# docker image ls
    REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
    10.10.0.110/busybox   v1                  64f5d945efcc        5 days ago          1.2MB
    busybox               latest              64f5d945efcc        5 days ago          1.2MB
    registry              latest              f32a97de94e1        2 months ago        25.8MB
    #将镜像推送到私有镜像仓库中
    [root@localhost ~]# docker push 10.10.0.110:80/busybox:v1
    The push refers to repository [10.10.0.110:80/busybox]
    d1156b98822d: Pushed 
    v1: digest: sha256:4fe8827f51a5e11bb83afa8227cbccb402df840d32c6b633b7ad079bc8144100 size: 527
    #测试拉取镜像
    [root@localhost repositories]# docker pull 10.10.0.110:80/busybox:v1
    v1: Pulling from busybox
    53071b97a884: Pull complete 
    Digest: sha256:4fe8827f51a5e11bb83afa8227cbccb402df840d32c6b633b7ad079bc8144100
    Status: Downloaded newer image for 10.10.0.110:80/busybox:v1

    七、查看当前私有仓库中有哪些镜像以及镜像的tag

    [root@localhost repositories]# curl  http://10.10.0.110:80/v2/_catalog 
    {"repositories":["busybox"]}
    [root@localhost repositories]# curl  http://10.10.0.110:80/v2/busybox/tags/list
    {"name":"busybox","tags":["v1"]}
  • 相关阅读:
    webpack前端构建工具学习总结(一)之webpack安装、创建项目
    当执行 import vue from 'vue' 时发生了什么?
    WEBSTORM新建VUE类型文件设置
    基于vue-cli搭建HelloWorld项目
    vue-cli脚手架安装
    浏览器的重绘和回流
    strcpy和strncpy用法和区别
    &与&&有什么区别?
    状态机实践入门
    12864点阵液晶显示模块的原理和实例程序(HJ12864M-1)
  • 原文地址:https://www.cnblogs.com/yyxianren/p/10870494.html
Copyright © 2011-2022 走看看