• Docker基础-搭建本地私有仓库


    1、使用registry镜像创建私有仓库

      安装Docker后,可以通过官方提供的registry镜像来简单搭建一套本地私有仓库环境:

    docker run -d -p 5000:5000 registry

    这条命令将自动下载并启动一个registry容器,创建本地的私有仓库服务。默认会将仓库创建在容器的/tmp/registry目录下。可以通过-v参数来将镜像文件存放在本地指定路径

    例如:将上传的镜像放到/opt/data/registry目录:

    docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry registry

    此时将在本地创建一个私有仓库服务,监听端口为5000。

    2.管理私有仓库

      docker本地私有仓库地址为10.0.0.32:5000
      首先在客户端查看本地镜像:

    [root@docker ~]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    ubuntu              16.04               20c44cd7596f        11 days ago         123MB
    ubuntu              latest              20c44cd7596f        11 days ago         123MB
    centos              latest              d123f4e55e12        3 weeks ago         197MB
    [root@docker ~]#

      将镜像通过docker tag修改镜像标签为10.0.0.32:5000/test:

    [root@docker ~]# docker tag ubuntu:16.04 10.0.0.32:5000/test
    [root@docker ~]# docker images
    REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
    10.0.0.32:5000/test   latest              20c44cd7596f        11 days ago         123MB
    ubuntu                16.04               20c44cd7596f        11 days ago         123MB
    ubuntu                latest              20c44cd7596f        11 days ago         123MB
    centos                latest              d123f4e55e12        3 weeks ago         197MB
    [root@docker ~]#

      由于docker仓库与客户端的https问题,需要修改/usr/lib/systemd/system/docker.service文件,添加 ExecStart=/usr/bin/dockerd --registry-mirror=https://1y8rn456.mirror.aliyuncs.com --insecure-registry 10.0.0.32:5000之后需要重启docker。

      使用docker push将镜像上传到私有仓库:

    [root@docker docker]# docker push 10.0.0.32:5000/test
    The push refers to a repository [10.0.0.32:5000/test]
    2f5b0990636a: Pushed
    c9748fbf541d: Pushed
    b3968bc26fbd: Pushed
    aa4e47c45116: Pushed
    788ce2310e2f: Pushed
    latest: digest: sha256:d4558f7616365813792918b6d73dc474bcacf99b13d1ed947731a653fb6e260c size: 1357

      拉取私有仓库镜像:

    [root@docker docker]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    ubuntu              16.04               20c44cd7596f        11 days ago         123MB
    ubuntu              latest              20c44cd7596f        11 days ago         123MB
    centos              latest              d123f4e55e12        3 weeks ago         197MB
    [root@docker docker]#
    [root@docker docker]# docker pull 10.0.0.32:5000/test
    Using default tag: latest
    latest: Pulling from test
    Digest: sha256:d4558f7616365813792918b6d73dc474bcacf99b13d1ed947731a653fb6e260c
    Status: Downloaded newer image for 10.0.0.32:5000/test:latest
    [root@docker docker]# docker images
    REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
    10.0.0.32:5000/test   latest              20c44cd7596f        11 days ago         123MB
    ubuntu                16.04               20c44cd7596f        11 days ago         123MB
    ubuntu                latest              20c44cd7596f        11 days ago         123MB
    centos                latest              d123f4e55e12        3 weeks ago         197MB
    [root@docker docker]#
  • 相关阅读:
    layui iframe版点击左侧菜单栏实现加载等待动画
    概率论基础内容
    fatal error LNK1123:转换COFF期间失败:文件无效或损坏
    ERROR 2003:Can't connect to MySQL server on ‘localhost’...
    HttpWebRequest 无法连接到远程服务器
    Android Error: java.lang.IllegalStateException: Could not execute method of the activity
    创建.aspx页面
    CodeFile Inherits
    Unable to execute dex:Target out of range
    fatal error C1083: 无法打开包括文件“jni.h”
  • 原文地址:https://www.cnblogs.com/jie-fang/p/7920078.html
Copyright © 2020-2023  润新知