zoukankan      html  css  js  c++  java
  • docker搭建本地registry

    第一步:拉取registry镜像

    [root@localhost iso]# docker image 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:8004747f1e8cd820a148fb7499d71a76d45ff66bac6a29129bfdbfdc0154d146
    Status: Downloaded newer image for registry:latest
    docker.io/library/registry:latest

    第二步:查看镜像构建历史信息

    [root@localhost iso]# docker image history registry
    IMAGE CREATED CREATED BY SIZE COMMENT
    f32a97de94e1 8 months ago /bin/sh -c #(nop) CMD ["/etc/docker/registr… 0B 
    <missing> 8 months ago /bin/sh -c #(nop) ENTRYPOINT ["/entrypoint.… 0B 
    <missing> 8 months ago /bin/sh -c #(nop) COPY file:507caa54f88c1f38… 155B 
    <missing> 8 months ago /bin/sh -c #(nop) EXPOSE 5000 0B 
    <missing> 8 months ago /bin/sh -c #(nop) VOLUME [/var/lib/registry] 0B 
    <missing> 8 months ago /bin/sh -c #(nop) COPY file:4544cc1555469403… 295B 
    <missing> 8 months ago /bin/sh -c #(nop) COPY file:21256ff7df5369f7… 20.1MB 
    <missing> 8 months ago /bin/sh -c set -ex && apk add --no-cache… 1.29MB 
    <missing> 8 months ago /bin/sh -c #(nop) CMD ["/bin/sh"] 0B 
    <missing> 8 months ago /bin/sh -c #(nop) ADD file:38bc6b51693b13d84… 4.41MB

    第三步:启动容器

    [root@localhost ~]# docker run --name refistry -d -p 8878:5000 -v /registry:/var/lib/registry registry 
    c2da1e4739006621455c09f1c319e67a063350b050d8cc4c07257b898a7536ce
    [root@localhost ~]# docker ps -a
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    c2da1e473900 registry "/entrypoint.sh /etc…" 50 seconds ago Up 50 seconds 0.0.0.0:8878->5000/tcp refistry

    第四步:镜像改名

    [root@localhost ~]# docker tag httpd 192.168.59.200:8878/http:test
    [root@localhost ~]# docker image ls
    REPOSITORY TAG IMAGE ID CREATED SIZE
    registry latest f32a97de94e1 8 months ago 25.8MB
    192.168.59.200:8878/http test fb2f3851a971 18 months ago 178MB
    httpd latest fb2f3851a971 18 months ago 178MB

    第五步:修改docker文件并重启

    [root@localhost docker]# vim daemon.json 
    {
    "registry-mirrors": ["https://XXX.mirror.aliyuncs.com"],
    "insecure-registries": ["192.168.59.200:8878"]
    }
    [root@localhost docker]# systemctl restart docker

    '''
    原因:

    [root@localhost ~]# docker image push 192.168.59.200:8878/http
    The push refers to repository [192.168.59.200:8878/http]
    Get https://192.168.59.200:8878/v2/: http: server gave HTTP response to HTTPS client

    '''

    第六步:重启registry容器

    [root@localhost docker]# docker ps -a
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    c2da1e473900 registry "/entrypoint.sh /etc…" 12 minutes ago Exited (2) About a minute ago refistry
    0400349ee7c8 httpd "httpd-foreground" 53 minutes ago Exited (0) About a minute ago httpd-test2
    e60cdf12daa7 httpd "httpd-foreground" About an hour ago Exited (0) About a minute ago http-test
    391afba79c84 httpd "httpd-foreground" About an hour ago Exited (0) About a minute ago httpd
    9225fd6da0e2 tomcat:test "catalina.sh run" 2 hours ago Exited (143) About a minute ago tomcat
    [root@localhost docker]# docker restart c2da1e473900

    第七步:推送

    [root@localhost docker]# docker image push 192.168.59.200:8878/http
    The push refers to repository [192.168.59.200:8878/http]
    0f8d971d177b: Pushed 
    97fd31ecd005: Pushed 
    82155933cfa6: Pushed 
    2fd9f57029b0: Pushed 
    02bd518ef304: Pushed 
    b8342f9976fc: Pushed 
    2c833f307fd8: Pushed 
    test: digest: sha256:58270ec746bed598ec109aef58d495fca80ee0a89f520bd2430c259ed31ee144 size: 1780
    [root@localhost docker]#

    第八步:查找本地库

    [root@localhost docker]# docker container inspect c2da1e473900|grep -i "source"
    "Source": "/registry",
    [root@localhost repositories]# cd
    [root@localhost ~]# cd /registry/docker/registry/v2/repositories
    [root@localhost repositories]# ls
    http
    [root@localhost repositories]# 

    附加:

    删除镜像

    [root@localhost ~]# docker image rm 192.168.59.200:8878/http

    拉取镜像:

    [root@localhost ~]# docker pull 192.168.59.200:8878/http
  • 相关阅读:
    使用C#调用Java带MIME附件WebService方法的初步设想
    到底是哪里给我插的广告?
    jQuery mobile X天教程 目录
    让ksoap支持wsse加密的soap报文
    第一天 认识jQuery mobile 框架,资源,书籍
    谈谈去那里找开源项目
    第二天 jQuery mobile 的Page&Dialogs,Toolbars,Button,listView全接触
    增强型MonkeyRunner 脚本计划
    以前我喜欢盗版,但是,我现在痛恨盗版
    android Handler 机制研究学习笔记
  • 原文地址:https://www.cnblogs.com/twoo/p/11820464.html
Copyright © 2011-2022 走看看