zoukankan      html  css  js  c++  java
  • docker 私有仓库搭建

    知识基础:ubuntu系统安装,docker安装,了解docker的基础知识

    下载镜像(如果下载2版本以上的需要配置ssl证书,这里先用0.9.1的演示)

    root@ubuntu:/# docker pull registry:0.9.1

    root@ubuntu:/# docker images
    REPOSITORY  TAG   IMAGE ID   CREATED   VIRTUAL   SIZE

    registry                         0.9.1               bdc26a966725        4 weeks ago          422.9 MB
    csphere/ent                      0.1                 f9118a2c0edc        3 weeks ago          212.1 MB
    root@ubuntu:/#

    生成容器(用编程的术语说:将镜像实例化出一个容器)

    端口号用5000,名称:registry  镜像文件和版本号:registry:0.9.1

    root@ubuntu:/# docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 --restart=always --name registry registry:0.9.1

    查看有哪些容器

    root@ubuntu:/# docker ps –a

    root@ubuntu:/# docker ps -a
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    9416c29b3cfd registry:0.9.1 "docker-registry" 45 minutes ago Up 14 minutes 0.0.0.0:5000->5000/tcp registry
    root@ubuntu:/#

    跳过,如果需要可删除没用的容器

    root@ubuntu:/# docker rm –f 容器ID

    用浏览器访问以下地址会出现一个弹出的下载窗口,证明私有仓库已安装好,后面是测试和修改配置步骤

    http://172.16.160.32:5000

    root@ubuntu:/# docker tag csphere/ent:0.1 172.16.160.32:5000/csphere/ent:0.1

    修改docker的配置,不然push的时候会报错。

    root@ubuntu:/# vi /etc/default/docker

    添加以下内容到配置文件中:

    DOCKER_OPTS="$DOCKER_OPTS --insecure-registry=172.16.160.32:5000"

    上传镜像到私有仓库

    root@ubuntu:/# docker push 172.16.160.32:5000/csphere/ent

    The push refers to a repository [172.16.160.32:5000/csphere/ent] (len: 1)

    Sending image list

    Pushing repository 172.16.160.32:5000/csphere/ent (1 tags)

    f1b10cd84249: Image successfully pushed

    172633e38420: Image successfully pushed

    fab4b1df8eb1: Image successfully pushed

    f9118a2c0edc: Image successfully pushed

    Pushing tag for rev [f9118a2c0edc] on {http://172.16.160.32:5000/v1/repositories/csphere/ent/tags/0.1}

    root@ubuntu:/#

    查询私有仓库内的镜像

    root@ubuntu:/#curl http://172.16.160.32:5000/v1/search

    {"num_results": 1, "query": "", "results": [{"description": "", "name": "csphere/ent"}]}

    root@ubuntu:/#

    root@ubuntu:/# docker rmi 172.16.160.32:5000/csphere/ent:0.1
    Untagged: 172.16.160.32:5000/csphere/ent:0.1
    Deleted: f9118a2c0edcf4782c8100d29fafde29dfc3e16aa4c17f648bd9ef03f9b4a6a0
    root@ubuntu:/#

    下载前确认已经没有csphere/ent镜像文件

    root@ubuntu:/# docker images

    以下命令从172.16.160.32:5000上的csphere目录下下载版本号为0.1的ent镜像。

    注:要指定IP地址不然会从公网上下载镜像,要指定版本,不然会提示找不到相应镜像。

    root@ubuntu:/# docker pull 172.16.160.32:5000/csphere/ent:0.1
    Pulling repository 172.16.160.32:5000/csphere/ent
    f9118a2c0edc: Download complete
    f1b10cd84249: Download complete
    172633e38420: Download complete
    fab4b1df8eb1: Download complete
    Status: Downloaded newer image for 172.16.160.32:5000/csphere/ent:0.1
    root@ubuntu:/#

    下载后确认有csphere/ent镜像文件

    root@ubuntu:/# docker images

    错误示范:

    root@ubuntu:/# docker pull 172.16.160.32:5000/csphere/ent
    Pulling repository 172.16.160.32:5000/csphere/ent
    FATA[0004] Tag latest not found in repository 172.16.160.32:5000/csphere/ent
    root@ubuntu:/# curl http://172.16.160.32:5000/v1/search
    {"num_results": 1, "query": "", "results": [{"description": "", "name": "csphere/ent"}]}root@ubuntu:/#
    root@ubuntu:/# docker pull csphere/ent
    Pulling repository csphere/ent
    FATA[0020] Error: image csphere/ent:latest not found
    root@ubuntu:/# docker pull csphere/ent:0.1
    Pulling repository csphere/ent
    FATA[0013] Error: image csphere/ent:0.1 not found

  • 相关阅读:
    js 实现图片上传
    关于IOS不能使用JQUERY的ON事件
    js实现复制
    订单列表倒计时
    小程序实现倒计时
    微信小程序服务消息推送
    python爬虫七
    python爬虫六
    python爬虫五
    python爬虫四
  • 原文地址:https://www.cnblogs.com/amoyzhu/p/5220309.html
Copyright © 2011-2022 走看看