Docker:私有仓库registry [十一]
一、运行docker私有仓库
安装registry
docker run -d -p 5000:5000 --restart=always --name registry -v /opt/myregistry:/var/lib/registry registry
当容器启动完成,私有仓库就可以使用了
二、上传到私有仓库的步骤:
1、给要上传的镜像打tag
[root@luoahong ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd latest ef1dc54703e2 2 weeks ago 132 [root@luoahong ~]# docker image tag httpd:latest 192.168.228.134:5000/httpd:latest
2、上传
[root@luoahong ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd latest ef1dc54703e2 2 weeks ago 132MB
[root@luoahong ~]# docker push 192.168.228.134:5000/httpd:latest
The push refers to repository [192.168.228.134:5000/httpd]
Get https://192.168.228.134:5000/v2/: http: server gave HTTP response to HTTPS client
3、报错解决方法
[root@luoahong ~]# vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://registry.docker-cn.com"],
"insecure-registries": ["192.168.228.134:5000"]
} [root@luoahong ~]# systemctl restart docker
[root@luoahong ~]# docker push 192.168.228.134:5000/httpd:latest
The push refers to repository [192.168.228.134:5000/httpd]
64446057e402: Pushed
13a694db88ed: Pushed
3fc0ec65884c: Pushed
30d0b099e805: Pushed
7b4e562e58dc: Pushed
latest: digest: sha256:246fed9aa9be7aaba1e04d9146be7a3776c9a40b5cfb3242d3427f79edee37db size: 1367
[root@luoahong ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd latest ef1dc54703e2 2 weeks ago 132MB
192.168.228.134:5000/httpd latest ef1dc54703e2 2 weeks ago 132MB
三、上传原理推导
1、客户端
[root@luoahong ~]# docker pull fedora:latest
latest: Pulling from library/fedora
d0483bd5a554: Pull complete
Digest: sha256:4a861283a7f0a8ce3d19b42f4c0a10d7012a4d12f785149d82a0800cdb4498b0
Status: Downloaded newer image for fedora:latest
[root@luoahong ~]# docker image tag fedora:latest 192.168.228.134:5000/fedora:latest
[root@luoahong ~]# docker push 192.168.228.134:5000/fedora:latest
The push refers to repository [192.168.228.134:5000/fedora]
a13f3c019d29: Pushed
latest: digest: sha256:f6d888e4caccb101aa540013d46089803f84f2b41b7ce70ef6b42e1ff4b33254 size: 529
2、私有仓库
没有推送fedora之前
[root@luoahong1 ~]# cd /opt/myregistry/docker/registry/v2/repositories/
[root@luoahong1 repositories]# ls
centos httpd
[root@luoahong1 repositories]# pwd
/opt/myregistry/docker/registry/v2/repositories
[root@luoahong1 repositories]# tree httpd/_manifests/
httpd/_manifests/
├── revisions
│ └── sha256
│ └── 246fed9aa9be7aaba1e04d9146be7a3776c9a40b5cfb3242d3427f79edee37db
│ └── link
└── tags
└── latest
├── current
│ └── link
└── index
└── sha256
└── 246fed9aa9be7aaba1e04d9146be7a3776c9a40b5cfb3242d3427f79edee37db
└── link
推送fedora之后
[root@luoahong1 repositories]# ls
centos fedora httpd
[root@luoahong1 repositories]# pwd
/opt/myregistry/docker/registry/v2/repositories
四、带base认证的私有仓库
0、没有带base认证前
[root@luoahong ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.228.134:5000/httpd latest ef1dc54703e2 2 weeks ago 132MB
httpd latest ef1dc54703e2 2 weeks ago 132MB
centos latest 1e1148e4cc2c 6 weeks ago 202MB
192.168.228.134:5000/fedora latest 8c568f104326 2 months ago 267MB
fedora latest 8c568f104326 2 months ago 267MB
centos 6.8 e54faac158ff 3 months ago 195MB
centos 6.9 e88c611d16a0 3 months ago 195MB
192.168.228.134:5000/centos 6.9 e88c611d16a0 3 months ago 195MB
[root@luoahong ~]# docker rmi centos:6.9 192.168.228.134:5000/centos:6.9
Untagged: centos:6.9
Untagged: centos@sha256:48623f1cc1ff287ef4843888bcee22285066adf2d5da6daf000070bee83cd93a
Untagged: 192.168.228.134:5000/centos:6.9
Untagged: 192.168.228.134:5000/centos@sha256:29b4ae1d59c681e6e8bb6f8eff1ec9f1c18cd24ae23b7d612e3a38c27a44f92f
Deleted: sha256:e88c611d16a001c1494b11a55bc25c0e9d63e67444d754d01f0ffa7de92a15c7 [root@luoahong ~]# docker pull 192.168.228.134:5000/centos:6.9
Error response from daemon: Get http://192.168.228.134:5000/v2/centos/manifests/6.9: no basic auth credentials
1、base认证密码文件准备
yum install httpd-tools -y
mkdir /opt/registry-var/auth/ -p
htpasswd -Bbn luoahong 123456 >> /opt/registry-var/auth/htpasswd
2、启动docker私有仓库
docker run -d -p 5000:5000 -v /opt/registry-var/auth/:/auth/ -v /opt/myregistry:/var/lib/registry -e "REGISTRY_AUTH=htpasswd" -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd registry
3、测试下载
[root@luoahong ~]# docker pull 192.168.228.134:5000/centos:6.9
Error response from daemon: Get http://192.168.228.134:5000/v2/centos/manifests/6.9: no basic auth credentials
[root@luoahong ~]#
[root@luoahong ~]# docker login 192.168.228.134:5000
Username: luoahong
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded
[root@luoahong ~]# cat /root/.docker/config.json
{
"auths": {
"192.168.228.134:5000": {
"auth": "bHVvYWhvbmc6MTIzNDU2"
}
},
"HttpHeaders": {
"User-Agent": "Docker-Client/18.09.1 (linux)"
}
}[root@luoahong ~]#docker pull 192.168.228.134:5000/centos:6.9
6.9: Pulling from centos
993c50d47469: Pull complete
Digest: sha256:29b4ae1d59c681e6e8bb6f8eff1ec9f1c18cd24ae23b7d612e3a38c27a44f92f
Status: Downloaded newer image for 192.168.228.134:5000/centos:6.9
[root@luoahong ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.228.134:5000/httpd latest ef1dc54703e2 2 weeks ago 132MB
httpd latest ef1dc54703e2 2 weeks ago 132MB
centos latest 1e1148e4cc2c 6 weeks ago 202MB
192.168.228.134:5000/fedora latest 8c568f104326 2 months ago 267MB
fedora latest 8c568f104326 2 months ago 267MB
centos 6.8 e54faac158ff 3 months ago 195MB
192.168.228.134:5000/centos 6.9 e88c611d16a0 3 months ago 195MB
4、私有仓库的缺点
私有仓库查看版本很麻烦
[root@luoahong1 repositories]# ls httpd/_manifests/tags/
latest
[root@luoahong1 repositories]# pwd
/opt/myregistry/docker/registry/v2/repositories
四、私有仓库缺点解决方案
1、查看镜像列表
使用浏览器访问:
http://192.168.228.134:5000/v2/_catalog

2、查看镜像列表
下面我已nginx为例
http://192.168.228.134:5000/v2/nginx/tags/list

3、删除镜像
1)进入docker registry的容器中
docker exec -it registry /bin/sh
2) 删除repo
rm -fr /var/lib/registry/docker/registry/v2/repositories/nginx
3) 清除掉:blob
registry garbage-collect /etc/docker/registry/config.yml
https://www.qstack.com.cn/archives/350.html
Docker:私有仓库registry [十一]的更多相关文章
- 转载:教你分分钟搞定Docker私有仓库Registry
一.什么是Docker私有仓库Registry 官方的Docker hub是一个用于管理公共镜像的好地方,我们可以在上面找到我们想要的镜像,也可以把我们自己的镜像推送上去.但是,有时候我们的服务器无法 ...
- 教你分分钟搞定Docker私有仓库Registry
一.什么是Docker私有仓库Registry 官方的Docker hub是一个用于管理公共镜像的好地方,我们可以在上面找到我们想要的镜像,也可以把我们自己的镜像推送上去.但是,有时候我们的服务器无法 ...
- (转)教你分分钟搞定Docker私有仓库Registry
转:https://www.cnblogs.com/Javame/p/7389093.html 一.什么是Docker私有仓库Registry 官方的Docker hub是一个用于管理公共镜像的好地方 ...
- Docker私有仓库registry的搭建及使用
前言 由于Docker Hub公共仓库很多时候使用这并不是很方便,大分部因为网络的问题可能拉取的时候会很慢或者拉取不到,所以搭建一个本地的私有仓库. 准备 由于此篇文章是在Kubernetes集群安装 ...
- Docker私有仓库Registry的搭建验证
1. 关于Registry 官方的Docker hub是一个用于管理公共镜像的好地方,我们可以在上面找到我们想要的镜像,也可以把我们自己的镜像推送上去.但是,有时候,我们的使用场景需要我们拥有一个私有 ...
- Docker私有仓库Registry 搭建
1. 关于Registry 官方的Docker hub是一个用于管理公共镜像的好地方,我们可以在上面找到我们想要的镜像,也可以把我们自己的镜像推送上去.但是,有时候,我们的使用场景需要我们拥有一个私有 ...
- Centos 7上Docker私有仓库Registry实战
1. 关于Registry 官方的Docker hub是一个用于管理公共镜像的好地方,我们可以在上面找到我们想要的镜像,也可以把我们自己的镜像推送上去.但是,有时候,我们的使用场景需要我们拥有一个私有 ...
- Docker私有仓库Registry实战
参考: https://www.cnblogs.com/soar1688/p/6828329.html 1. 关于Registry 官方的Docker hub是一个用于管理公共镜像的好地方,我们可以在 ...
- docker私有仓库registry的使用
1.registry的安装 关于docker registry的安装,可以说简单的不能再简单了,docker run一个容器就好了,也就是一条命令的事 docker run -d -p : --res ...
随机推荐
- 列表、enumerate()函数,以及查看数据类型所有的内置方法
随便看看 """ forList(): 测试list和enumerate()函数 examineFun(): 查看数据类型所有的内置方法 ""&quo ...
- 对于windows操作系统磁盘访问权限修改的手残教训
最近公司新配置的win10电脑,由于测试关于windows系统上项目的安装程序时默认使用了c盘安装,发现安装后的项目不是崩溃就是运行没结果的,偶然间发现同一个安装程序在d盘或其他非系统盘安装则正常.很 ...
- jest 自动化测试
概述 jest 是 facebook 开源的,用来进行单元测试的框架,可以测试 javascipt 和 react. 单元测试各种好处已经被说烂了,这里就不多扯了.重点要说的是,使用 jest, 可以 ...
- Django REST framework基础:视图和路由
DRF中的Request 在Django REST Framework中内置的Request类扩展了Django中的Request类,实现了很多方便的功能--如请求数据解析和认证等. 比如,区别于Dj ...
- css_选择器
老师的博客:https://www.cnblogs.com/liwenzhou/p/7999532.html 参考w3 school:http://www.w3school.com.cn/css/cs ...
- 第一节 anaconda+jupyter+numpy简单使用
数据分析:是把隐藏在一些看似杂乱无章的数据背后的信息提炼出来,总结出所研究对象的内在规律 数据分析三剑客:Numpy,Pandas,Matplotlib 一 Anaconda 1 下载 官网:http ...
- 浅析foreach语句
本篇是我对于foreach语句(增强for)的总结: 我的总结流程如下: 1.先整体说明增强for遍历集合与数组之间的区别. 2.通过一维数组来说明(给出反编译的源码,形成对照). 3.通过二维数组来 ...
- 【MOS】在不同版本和平台之间进行还原或复制 (文档 ID 1526162.1)--跨版本恢复
参考链接:http://blog.itpub.net/26736162/viewspace-1549041/
- Java 200+ 面试题补充 ThreadLocal 模块
让我们每天都有进步,老王带你打造最全的 Java 面试清单,认真把一件事做到极致. 本文是前文<Java 最常见的 200+ 面试题>的第一个补充模块. 1.ThreadLocal 是什么 ...
- 算法笔记-状压dp
状压dp 就是把状态压缩的dp 这样还是一种暴力但相对于纯暴力还是优雅的多. 实际上dp就是经过优化的暴力罢了 首先要了解位运算 给个链接吧 [https://blog.csdn.net/u01337 ...