zoukankan      html  css  js  c++  java
  • 在Ubuntu14.04系统POWER8服务器上搭建Docker Registry服务

    本文描述了如何在POWER8服务器上搭建一个本地化的Docker镜像仓库,主要涉及镜像制作,Docker Registry服务启动等。希望能够对在非X86服务器上搭建Docker仓库的同学提供参考。
    声明:本文仅作为个人学习使用!


    第一步,在服务器上启动一个KVM虚拟机(ip: 172.16.13.221),编译Docker生成可执行文件,启动Docker Daemon服务。可参考我的另一篇文档。

    第二步,制作Registry镜像
      由于Ubuntu环境中暂时还没有docker registry镜像,需要自己制作
      1,制作Ubuntu14:04基础镜像
      $ sudo apt-get install -y debootstrap
      $ curl -o debootstrap.sh https://raw.githubusercontent.com/docker/docker/master/contrib/mkimage/debootstrap
      $ chmod 755 debootstrap.sh
      $ sudo ./debootstrap.sh ubuntu --components=main,universe trusty
      $ sudo tar -C ubuntu -c . | docker import - ubuntu:14.04
      $ docker tag ubuntu:14.04 ubuntu:trusty
      $ docker tag ubuntu:14.04 ubuntu:latest
      $ sudo rm -fr ubuntu

      $ docker images
      REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
      ubuntu 14.04 78c113d93188 59 seconds ago 197.6 MB
      ubuntu latest 78c113d93188 59 seconds ago 197.6 MB
      ubuntu trusty 78c113d93188 59 seconds ago 197.6 MB

      2,下载docker-registry
      $ git clone https://github.com/docker/docker-registry
      3,打补丁
      $ cd ~/docker-registry
      $ cat ~/docker-registry/docker-registry.patch
    *** docker-registry.orig/Dockerfile Sat Jan 31 07:20:32 2015
    --- docker-registry/Dockerfile Sat Jan 31 13:12:11 2015
    ***************
    *** 19,24 ****
    --- 19,27 ----
    libssl-dev
    liblzma-dev
    libevent1-dev
    + # Install deps for building gevent
    + curl
    + cython
    && rm -rf /var/lib/apt/lists/*

    COPY . /docker-registry
    ***************
    *** 27,32 ****
    --- 30,45 ----
    # Install core
    RUN pip install /docker-registry/depends/docker-registry-core

    + # Install gevent 1.0.1 using updated config.guess and config.sub
    + RUN curl https://pypi.python.org/packages/source/g/gevent/gevent-1.0.1.tar.gz | tar -xzf - -C /
    + && curl -o /gevent-1.0.1/libev/config.guess
    + 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD'
    + && curl -o /gevent-1.0.1/libev/config.sub
    + 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD'
    + && cp -pf /gevent-1.0.1/libev/config.guess /gevent-1.0.1/c-ares/config.guess
    + && cp -pf /gevent-1.0.1/libev/config.sub /gevent-1.0.1/c-ares/config.sub
    + && pip install /gevent-1.0.1
    +
    # Install registry
    RUN pip install file:///docker-registry#egg=docker-registry[bugsnag,newrelic,cors]
      $ patch -p1 < docker-registry.patch


      4,制作Registry镜像
      $ docker build -t registry .
      Removing intermediate container bc9ea34e0252
      Successfully built 2be3e95c5b2f


    第三步,启动Registry服务
      $ docker run -d -p 5000:5000 registry
      [2015-12-09 06:28:48 +0000] [1] [INFO] Starting gunicorn 19.1.1
      [2015-12-09 06:28:48 +0000] [1] [INFO] Listening at: http://0.0.0.0:5000 (1)
      [2015-12-09 06:28:48 +0000] [1] [INFO] Using worker: gevent
      [2015-12-09 06:28:48 +0000] [13] [INFO] Booting worker with pid: 13
      [2015-12-09 06:28:48 +0000] [14] [INFO] Booting worker with pid: 14
      ......

      $ docker ps
      CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
      266b27fb6d5b registry "docker-registry" 22 seconds ago Up 20 seconds 0.0.0.0:5000->5000/tcp goofy_jennings

    第四步,上传镜像到registry
      我在有Registry容器的KVM中上传镜像总是遇到连接错误,后来没有解决。就尝试在另一个KVM里面上传,结果成功了。
      1,在另一个KVM中启动docker Daemon
      2,使用docker import将之前制作的文件放入本地docker 系统中
      3,配置docker.conf文件,设置registry地址(172.16.13.221:5000),使用--insecure-registry参数,然后restart docker Daemon。
      在/ect/init/docker.conf中添加
      DOCKER_OPTS="--insecure-registry 172.16.13.221:5000"

      $ps -aux
      /usr/bin/docker daemon --insecure-registry 172.16.13.221:5000
      4,给待上传的镜像打上tag
      $ docker tag f3b2472e2593 172.16.13.221:5000/ubuntu
      $ docker images
      REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
      172.16.13.221:5000/ubuntu latest f3b2472e2593 2 days ago 188.3 MB
      ubuntu 14.04 f3b2472e2593 2 days ago 188.3 MB
      ubuntu latest f3b2472e2593 2 days ago 188.3 MB
      ubuntu trusty f3b2472e2593 2 days ago 188.3 MB
      5,Push镜像(传输可能中断,需要多尝试几次)
      $ docker push 172.16.13.221:5000/ubuntu
      The push refers to a repository [localhost:5000/ubuntu] (len: 1)
      Sending image list
      Pushing repository 172.16.13.221:5000/ubuntu (1 tags)
      f3b2472e2593: Image successfully pushed

      $ docker search 172.16.13.221:5000/ubuntu
      NAME DESCRIPTION STARS OFFICIAL AUTOMATED
      library/ubuntu 0


    参考资料:
      Build and use Docker on the IBM POWER Linux platform
      https://www.ibm.com/developerworks/library/d-docker-on-power-linux-platform/

  • 相关阅读:
    idea 快捷键
    上传代码
    maven 打包
    mysql 通过测试'for update',深入了解行锁、表锁、索引
    mysql中,手动提交事务
    java 发送邮件
    zk脑裂
    malloc,free和new,delete之间的区别
    sizeof和strlen区别
    字符串常量问题
  • 原文地址:https://www.cnblogs.com/rodenpark/p/5036133.html
Copyright © 2011-2022 走看看