zoukankan      html  css  js  c++  java
  • [docker]本地仓库的创建的使用

    如果自己创建的镜像可以供其他同事使用,那就可以大大节约开发时间成本,docker的本地仓库正好可以满足这样的需求

    1、在仓库服务器上创建本地仓库

    baylor@baylor-virtual-machine:~$ docker run -d -p 5000:5000 --name registry registry:2

    2、在需要上传的服务器上先得到个镜像

    baylor@baylor-virtual-machine:~$ docker pull busybox

    3、为准备上传的镜像改个tag

    baylor@baylor-virtual-machine:~$ docker tag busybox 192.168.133.165:5000/busybox

    4、将本地的镜像推送到本地仓库服务器

    baylor@baylor-virtual-machine:~$ docker push 192.168.133.165:5000/busybox

    可能会遇到以下的错误信息:

    FATA[0000] Error response from daemon: v1 ping attempt failed with error: Get https://192.168.133.165:5000/v1/_ping: local error: record overflow. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry 192.168.133.165:5000` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/192.168.133.165:5000/ca.crt 

    因为Docker从1.3.X之后默认docker registry使用的是https,所以当用docker pull命令下载远程镜像时,如果远程docker registry是非https的时候就会报上面的错误。

    解决方法为在docker的配置文件里添加--insecure-registry参数

    baylor@baylor-virtual-machine:~$ cat /etc/default/docker 
    # Docker Upstart and SysVinit configuration file
    
    # Customize location of Docker binary (especially for development testing).
    #DOCKER="/usr/local/bin/docker"
    
    # Use DOCKER_OPTS to modify the daemon startup options.
    #DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
    
    # If you need Docker to use an HTTP proxy, it can also be specified here.
    #export http_proxy="http://127.0.0.1:3128/"
    
    # This is also a handy place to tweak where Docker's temporary files go.
    #export TMPDIR="/mnt/bigdrive/docker-tmp"
    DOCKER_OPTS="--insecure-registry 192.168.133.165:5000"     《-------在这里

    5、重启docker后再次推送

    baylor@baylor-virtual-machine:~$ sudo service docker restart

    6、到另外一台机器上去拉镜像(如果也有证书问题,说明也要需要在/etc/default/docker的配置文件里添加registry参数的)

    baylor@baylor-virtual-machine:~$ docker pull 192.168.133.165:5000/busybox

    7、注意:

    因为本地仓库也是一个容器,那么当这个窗口被误删除时,它里面的镜像也会随之删除。所以在创建这个容器的时候最好使用-v参数将数据持久化

    我创建的本地仓库存放其它镜像的地址是/var/lib/registry/docker/registry/v2/repositories/,各位在使用的时候情况可能有所不同

    baylor@baylor-virtual-machine:~$ sudo docker run -d -p 5000:5000 -v /opt/data/registry:/var/lib/registry/docker/registry/v2/repositories/ --name registry
  • 相关阅读:
    SAP OPEN UI5 Step 8: Translatable Texts
    SAP OPEN UI5 Step7 JSON Model
    SAP OPEN UI5 Step6 Modules
    SAP OPEN UI5 Step5 Controllers
    SAP OPEN UI5 Step4 Xml View
    SAP OPEN UI5 Step3 Controls
    SAP OPEN UI5 Step2 Bootstrap
    SAP OPEN UI5 Step1 环境安装和hello world
    2021php最新composer的使用攻略
    Php使用gzdeflate和ZLIB_ENCODING_DEFLATE结果gzinflate报data error
  • 原文地址:https://www.cnblogs.com/baylorqu/p/9541375.html
Copyright © 2011-2022 走看看