使用官方 docker registry 搭建私有镜像仓库及部署 web ui

本文介绍本人在 Centos 7.1 上的搭建过程 private docker registry 的全过程,参考自这篇 官网文档,英语好的可以直接看官网文档,里面的内容更详细,涉及更多原理性的东西,而本文侧重于动手实践。
本文不介绍 docker 的基础概念,也不介绍为什么要搭建 private docker registry(这方面的内容网上有太多文档)。并且,虽然可以在好几种不同的环境中搭建,但本文只介绍在 Centos 7.1 上的搭建过程,其它版本的系统搭建过程,也请查阅上面给出过的 官网文档

先安装 docker 1.6 或更高版本

0. 前提条件

需要 centos 7 64位系统,且内核版本最少为 3.10。可通过下面指令检查你的内核版本:
$ uname -r
3.10.0-229.14.1.el7.x86_64

1.安装

安装 docker 有三种方式:
  • 通过源码安装。又可分为两种方式,完全通过源码安装和通过 docker 自身完成安装。前一种方式不仅非常复杂,而且网上介绍的文章很少,这里不介绍。后一种需要你的主机已经安装了 docker,这个要求有点先有鸡还是先有蛋的意味,这里也不介绍。
  • 通过 yum 安装。这种方式最简单,正是本文要介绍的,它会自动帮你下载安装各种依赖文件。
  • 通过 curl 来安装。这种方式其实是运行一个安装脚本,在这个脚本里面也是通过 yum 来安装的。

通过 yum 安装的步骤如下:
1.1,使用 root 或其它有 sudo 权限的账号登录进系统。以下过程假设你使用 root 登录,如果是其它账号,请在命令最前面加上 sudo。

1.2,确保你的 yum 包是最新的
$ yum update

1.3,添加 yum 仓库源
tee /etc/yum.repos.d/docker.repo <<-'EOF'
> [dockerrepo]
> name=Docker Repository
> baseurl=https://yum.dockerproject.org/repo/main/centos/7/
> enabled=1
> gpgcheck=1
> gpgkey=https://yum.dockerproject.org/gpg
> EOF

1.4,安装 docker 包
$ yum install docker-engine

1.5,启动 docker 守护进程
$ service docker start

1.6,到这一步安装 docker 就算完成了,我们可以运行一个 hello-world 容器来验证一下安装是否正确
$ sudo docker run hello-world 
 Unable to find image 'hello-world:latest' locally 
        latest: Pulling from hello-world 
        a8219747be10: Pull complete 
        91c95931e552: Already exists 
        hello-world:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security. 
        Digest: sha256:aa03e5d0d5553b4c3473e89c8619cf79df368babd1.7.1cf5daeb82aab55838d 
        Status: Downloaded newer image for hello-world:latest 
        Hello from Docker. 
        This message shows that your installation appears to be working correctly. 

        To generate this message, Docker took the following steps: 
         1. The Docker client contacted the Docker daemon.
         2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (Assuming it was not already locally available.)
         3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.
         4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.

         To try something more ambitious, you can run an Ubuntu container with: 
          $ docker run -it ubuntu bash 

         For more examples and ideas, visit: 
          http://docs.docker.com/userguide/


出现上述这样的输出,就说明安装正确了。
    

2.创建一个 docker 用户组

docker 守护进程绑定到一个 unix socket 而不是 tcp 端口。默认情况下,这个 unix socket 的所有者是 root,其他用户需要通过 sudo 的方式访问。因为 docker
  • 8
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值