美文网首页Docker
Docker搭建私有镜像仓库

Docker搭建私有镜像仓库

作者: kongxx | 来源:发表于2017-11-03 09:14 被阅读293次

现在Docker用处越来越多了,所以今天就想着搭建一个私有镜像仓库来维护内部我们自己的镜像。

环境

  • CentOS 7.x
  • Docker 1.12.6

安装 docker-distribution

$ sudo yum install -y docker-distribution

$ sudo systemctl enable docker-distribution

$ sudo systemctl start docker-distribution

使用

获取测试镜像

首先从Docker中央仓库获取一个用来测试的容器镜像,这里就使用busybox来作为测试镜像。

$ sudo docker pull busybox

$ sudo docker images
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
docker.io/busybox             latest              9d7e6df8e5ca        8 hours ago         1.129 MB

标记并上传镜像私有镜像

我们这里不对busybox做任何修改,只是换个名字作为私有镜像。

$ sudo docker tag busybox:latest localhost:5000/kongxx/mybusybox:latest
$ sudo docker push localhost:5000/kongxx/mybusybox:latest

上传完成后可以使用下面命令查看一下

$ curl http://192.168.0.109:5000/v2/kongxx/busybox/tags/list
{"name":"kongxx/busybox","tags":["latest"]}

同时我们查看一下本地的镜像列表

$ sudo docker images
REPOSITORY                        TAG                 IMAGE ID            CREATED             SIZE
localhost:5000/kongxx/mybusybox   latest              9d7e6df8e5ca        8 hours ago         1.129 MB
docker.io/busybox                 latest              9d7e6df8e5ca        8 hours ago         1.129 MB

测试镜像仓库

为了能访问私有仓库(因为这里是自己测试,所以没有使用https),还需要修改一下Docker配置文件

编辑 /etc/sysconfig/docker 文件,将其中的 OPTIONS 参数加上

--insecure-registry 192.168.0.109:5000

然后重新启动Docker服务

$ sudo systemctl restart docker

为了测试,我们先把原来本地已经有的镜像删除

$ sudo docker rmi docker.io/busybox
$ sudo docker rmi localhost:5000/kongxx/mybusybox

然后重新获取镜像,如下:

$ sudo docker pull 192.168.0.109:5000/kongxx/mybusybox
Using default tag: latest
Trying to pull repository 192.168.0.109:5000/kongxx/mybusybox ...
latest: Pulling from 192.168.0.109:5000/kongxx/mybusybox
414e5515492a: Pull complete
Digest: sha256:fbcd856ee1f73340c0b7862201b9c045571d1e357797e8c4c0d02a0d21992b80

从输出可以看到已经可以从自己的仓库下载镜像了。

其他

最后说一下,如果要查询私有仓库里有哪些镜像,我还没有找到啥好方法可以一次全部查到,但是可以通过下面的组合命令来查询。

首先查询私有仓库上有那些镜像名

$ curl -XGET http://192.168.0.109:5000/v2/_catalog
{"repositories":["kongxx/mybusybox","mandy/mybusybox"]}

然后使用下面的命令查看镜像有那些版本

# curl -XGET http://192.168.0.109:5000/v2/<image_name>/tags/list
$ curl -XGET http://192.168.0.109:5000/v2/kongxx/mybusybox/tags/list
{"name":"kongxx/mybusybox","tags":["latest"]}

相关文章

  • 5.私有与公有镜像仓库

    一. 搭建私有镜像仓库 Docker Hub作为Docker默认官方公共镜像;如果想自己搭建私有镜像仓库,官方也提...

  • Docker

    构建镜像仓库 Docker运行java程序 1.1.6 搭建docker私有仓库 新建私有仓库 1.2.1 数据挂...

  • Docker之八私有仓库

    个人专题目录 Docker 私有仓库 1. 私有仓库搭建 2. 将镜像上传至私有仓库 3. 从私有仓库拉取镜像

  • Docker

    一、搭建私有镜像仓库 说明:1、 这里是通过阿里云,搭建Docker私有镜像仓库。2、 这里打包的镜像是从官网拉下...

  • Docker搭建私有仓库之Harbor

    Docker搭建私有仓库之Harbor Harbor Harbor是构建企业级私有docker镜像的仓库的开源解决...

  • docker.镜像仓库

    第七节.镜像仓库 搭建私有镜像仓库下载registry镜像并启动docker pull registrydocke...

  • 【docker学习笔记九】Docker的registry私服

    1、私有仓库搭建与配置 2、镜像上传至私有仓库 格式是:docker tag (镜像的名字/id):tag ip...

  • Docker私有仓库

    一、Docker私有仓库搭建与配置 1、拉取私有仓库镜像 2、启动私有仓库容器 3、打开浏览器输入地址http:/...

  • 微服务笔记26:镜像仓库与资源调度

    镜像仓库 仓库的作用是用来保存Docker镜像的,进行集中式的存储。私有仓库搭建一般需要保证权限,镜像同步,高可用...

  • Harbor .v1.10.2 私有镜像仓库的自签CA证书、安装

    需求 在以前搭建docker镜像私有仓库的时候,我都是使用registery搭建。本篇章来尝试另一个新的镜像仓库H...

网友评论

    本文标题:Docker搭建私有镜像仓库

    本文链接:https://www.haomeiwen.com/subject/tzbzpxtx.html