一,启动docker后,搜索registry

[root@localhost source]# systemctl start docker
[root@localhost source]# docker search registry
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
registry The Docker Registry 2.0 implementation for s… 2873 [OK]

说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

对应的源码可以访问这里获取: https://github.com/liuhongdi/

说明:作者:刘宏缔 邮箱: 371125307@qq.com

二,下载registry容器

1,下载

[root@localhost docker]# docker pull registry

2,查看本地的镜像:

[root@localhost docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry latest 708bc6af7e5e 6 weeks ago 25.8MB

三,启动registry

1,启动registry

[root@localhost docker]# docker run -d -p 5000:5000 -v /data/docker/registry:/var/lib/registry --privileged=true --restart=always --name registry registry:latest
0e48cc6c0871bf2d5a0ee0208d3e87ae0cf4706dada93c7e80133fa22f7bbaef
[root@localhost docker]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0e48cc6c0871 registry:latest "/entrypoint.sh /etc…" 7 seconds ago Up 5 seconds 0.0.0.0:5000->5000/tcp registry

2,查看registry的ip地址

[root@localhost docker]# docker inspect registry | grep IPAddress
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.2",
"IPAddress": "172.17.0.2",

3,用浏览器访问5000端口,判断是否安装成功:

这个地址:

http://172.17.0.2:5000/v2/

四,查看私有库的镜像列表:

[root@localhost docker]# curl http://172.17.0.2:5000/v2/_catalog
{"repositories":[]}

五,我们制作一个基于centos8的nfs的镜像

参见:

docker19.03制作一个基于centos8的带有nfs4服务的镜像
地址:https://www.cnblogs.com/architectforest/p/12495958.html

六,上传一个镜像到私有库

我们把上面制作的镜像上传到我们搭建的私有库

1,给当前镜像打上tag:

[root@localhost ~]# docker tag nfsnginx:0.1 172.17.0.2:5000/nfsnginx:0.1

查看打tag后的效果

[root@localhost ~]# docker images | grep nfsnginx
172.17.0.2:5000/nfsnginx 0.1 fa72df9fb744 3 hours ago 328MB
nfsnginx 0.1 fa72df9fb744 3 hours ago 328MB

2,开始push

[root@localhost ~]# docker push 172.17.0.2:5000/nfsnginx:0.1
The push refers to repository [172.17.0.2:5000/nfsnginx]
Get https://172.17.0.2:5000/v2/: http: server gave HTTP response to HTTPS client

这个报错是什么?

Docker与Docker Registry交互默认使用https协议,

我们搭建的Docker Registry只提供http服务,

当和Registry私有仓库交互时会失败,

为解决这个问题,我们启动Docker时配置Registry不安全选项即可

说明:要用防火墙限制私有库的访问,不允许端口从公网上随便访问

3,解决上面的那个报错:

[root@localhost ~]# vi /etc/docker/daemon.json

增加一行:

"insecure-registries":["172.17.0.2:5000"]

看例子:

[root@localhost ~]# more /etc/docker/daemon.json
{
"registry-mirrors":["https://o3trwnyj.mirror.aliyuncs.com"],
"insecure-registries":["172.17.0.2:5000"]
}

然后重启docker服务:

[root@localhost ~]# systemctl restart docker

并再次启动容器

[root@localhost ~]# docker start registry
registry

4,再次push:

[root@localhost ~]# docker push 172.17.0.2:5000/nfsnginx:0.1
The push refers to repository [172.17.0.2:5000/nfsnginx]
28dd39094cf0: Pushed
0683de282177: Pushed
0.1: digest: sha256:98417504960cfd0c3ddbb61f18ac8ed7e4737136cc8640f1d24c0f8f5d4eb1fe size: 741

5,上传是否成功?我们从浏览器访问这个地址:

http://172.17.0.2:5000/v2/_catalog

响应内容为:

{"repositories":["nfsnginx"]}

可以确认已上传成功

6,查看已上传镜像的tag列表:

从浏览器访问这个地址:

http://172.17.0.2:5000/v2/nfsnginx/tags/list

说明:nfsnginx是我们所上传的镜像的名字

七,从私有库下载一个镜像

从另一台安装有docker的服务器上测试:

1,执行docker的pull命令:

[root@localhost liuhongdi]# docker pull 192.168.1.8:5000/nfsnginx:0.1
Error response from daemon: Get https://192.168.1.8:5000/v2/: http: server gave HTTP response to HTTPS client

说明:192.168.1.8是上面搭建registry的docker宿主机的ip

2,解决方法同上:

[root@localhost liuhongdi]# vi /etc/docker/daemon.json

增加一行:

"insecure-registries":["192.168.1.8:5000"]

然后重启docker:

[root@localhost liuhongdi]# systemctl restart docker

3,再次测试:

[root@localhost liuhongdi]# docker pull 192.168.1.8:5000/nfsnginx:0.1
0.1: Pulling from nfsnginx
8a29a15cefae: Already exists
b3f2d668510c: Pull complete
Digest: sha256:98417504960cfd0c3ddbb61f18ac8ed7e4737136cc8640f1d24c0f8f5d4eb1fe
Status: Downloaded newer image for 192.168.1.8:5000/nfsnginx:0.1

4,查看下载是否成功

[root@localhost liuhongdi]# docker images | grep nfsnginx
192.168.1.8:5000/nfsnginx 0.1 fa72df9fb744 4 hours ago 328MB

八,查看docker的版本

[root@localhost source]# docker --version
Docker version 19.03.7, build 7141c19

docker19.03搭建私有容器仓库的更多相关文章

  1. [转]Ubuntu18.04下使用Docker Registry快速搭建私有镜像仓库

    本文转自:https://blog.csdn.net/BigData_Mining/article/details/88233015 1.背景 在 Docker 中,当我们执行 docker pull ...

  2. Android业务组件化之Gradle和Sonatype Nexus搭建私有maven仓库

    前言: 公司的业务组件化推进的已经差不多三四个月的时间了,各个业务组件之间的解耦工作已经基本完成,各个业务组件以module的形式存在项目中,然后项目依赖本地的module,多少有点不太利于项目的并行 ...

  3. 【Docker】(4)搭建私有镜像仓库

    [Docker](4)搭建私有镜像仓库 说明 1. 这里是通过阿里云,搭建Docker私有镜像仓库. 2. 这里打包的镜像是从官网拉下来的,并不是自己项目创建的新镜像,主要测试功能 一.搭建过程 首先 ...

  4. 使用Sinopia搭建私有npm仓库

    使用Sinopia搭建私有npm仓库 在用npm装包的时候,每次都要下载一大堆,慢且不说,npm还老被墙,所以就想到在公司内部搭建npm仓库镜像.大概看了几个,觉得Sinopia最简单也好用,所以就使 ...

  5. 搭建私有Nuget仓库

    使用Nexus搭建私有Nuget仓库 https://www.cnblogs.com/Erik_Xu/p/9211471.html 前言 Nuget是ASP .NET Gallery的一员,是免费.开 ...

  6. 在阿里云上搭建私有GIT仓库

    在阿里云上搭建私有GIT仓库 年轻人就得好好学习,不能这么颓废 最近做项目练练手,用到了github, 但是github访问速度是真的慢啊,下载项目,下载一天了.所以呢,我是个成熟的人了,只好自己搭建 ...

  7. 详解docker实战之搭建私有镜像仓库 - kurbernetes

    1.实战目的 搭建企业私有的镜像仓库,满足从开发环境推送和拉取镜像.当我们使用k8s来编排和调度容器时,操作的基本单位是镜像,所以需要从仓库去拉取镜像到当前的工作节点.本来使用公共的docker hu ...

  8. [转] 使用HTTPS在Nexus Repository Manager 3.0上搭建私有Docker仓库

    FROM: https://www.hifreud.com/2018/06/06/03-nexus-docker-repository-with-ssl/ 搭建方式 搭建SSL的Nexus官方提供两种 ...

  9. docker 搭建私有云仓库

    docker搭建私有仓库   registry私有仓库 下载docker-distribution软件包 yum install epel-release yum install docker-dis ...

随机推荐

  1. HTML -- 表单元素2

    (1)<select>元素(下拉列表) <html> <body> <!-- 表单处理程序在action属性中指定 --> <form actio ...

  2. oracle之三rman 维护

    rman 维护 11.1 rman 使用和维护 11.2 list 命令一览 1)RMAN> list backup; 2)RMAN> list backup of tablespace ...

  3. oracle之三手工不完全恢复

    手工不完全恢复 4.1 不完全恢复的特点: 1)让整个database 回到过去某个时间点,不能避免数据丢失. 2)想跳过坏日志而继续恢复所有其他工作是不可能的,前滚没有这个功能(考点). 3)必须以 ...

  4. 吴恩达《深度学习》-第五门课 序列模型(Sequence Models)-第三周 序列模型和注意力机制(Sequence models & Attention mechanism)-课程笔记

    第三周 序列模型和注意力机制(Sequence models & Attention mechanism) 3.1 序列结构的各种序列(Various sequence to sequence ...

  5. 软件工程与UML作业2

    博客班级 https://edu.cnblogs.com/campus/fzzcxy/2018SE1 作业要求 https://edu.cnblogs.com/campus/fzzcxy/2018SE ...

  6. async/await 深度理解使用

    在vue中使用 eg async created () { await setTimeout(()=>{ console.log(1) },5000); }, async mounted () ...

  7. cnblog维护

    title: 博客归纳 blog: CSDN data: Java学习路线及视频 2019 12/31 时间管理 2020 1/22 Git是什么? 1/23 Git安装--Windows 3/24 ...

  8. Azure 内容审查器之文本审查

    内容审查器 Azure 内容审查器也是一项认知服务.它支持对文本.图形.视频进行内容审核.可以过滤出某些不健康的内容,关键词.使你的网站内容符合当地的法律法规,提供更好的用户体验. 文本内容审核 其中 ...

  9. Python练习题 037:Project Euler 009:毕达哥拉斯三元组之乘积

    本题来自 Project Euler 第9题:https://projecteuler.net/problem=9 # Project Euler: Problem 9: Special Pythag ...

  10. 山寨一个Spring的@Component注解

    1. 前言 我们在上一篇对Mybatis如何将Mapper接口注入Spring IoC进行了分析,有同学问胖哥这个有什么用,这个作用其实挺大的,比如让你实现一个类似@Controller的注解(或者继 ...