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 ...
随机推荐
- Linux 文件权限管理
1.文件权限的概述 在Linux系统下,使用权限来保护资源的安全将是一种不错的选择.系统中每个文件的权限都有可读(r).可写(w)和可执行(x)这三种权限,它们分别对应权限数值4.2 和1.系统为每个 ...
- 【导航】Python相关
[博客导航] Python相关导航 [索引]Python常用资源(从新手到大牛) [任务]Python语言程序设计.MOOC学习 [笔记]Python集成开发环境——PyCharm 2018.3下载. ...
- Java实现Sunday百万级数据量的字符串快速匹配算法
背景 在平时的项目中,几乎都会用到比较两个字符串时候相等的问题,通常是用==或者equals()进行,这是在数据相对比较少的情况下是没问题的,当数据库中的数据达到几十万甚至是上百万千万的数 ...
- Enterprise Architect 时序图
添加时序图 1,在类图下面新建包 添加sequence时序图 点击流程控制,可以打开流程控制设计界面 我选择的是Lifeline线,你可以选择都差不多. 点击其中一条liftline连到其他上面 双击 ...
- [已决解]关于Hadoop start-all.sh启动问题
问题一:出现Attempting to operate on hdfs namenode as root 写在最前注意: 1.master,slave都需要修改start-dfs.sh,stop-df ...
- UUID简记
一.概述 wiki上的解释: A universally unique identifier (UUID) is a 128-bit number used to identify informati ...
- Linux内存管理 (15)页面迁移
专题:Linux内存管理专题 关键词:RMAP.页面迁移. 相关章节:反向映射RMAP.内存规整. 页面迁移的初衷是为NUMA系统提供一种将进程迁移到任意内存节点的能力,后来内存规整和内存热插拔场景都 ...
- js获取response头信息
当我们使用ajax发起请求时,经常需要获取请求返回的头信息.默认情况下,js货可以获取如下头信息: Cache-Control Content-Language Content-Type Expirs ...
- Python Revisited Day 13 (正则表达式)
目录 13.1 Python的正则表达式语言 13.1.1 字符与字符类 13.1.2 量词 {m, n} ? + * 组与捕获 ?:可以关闭捕获 断言与标记 13.2 正则表达式模块 正则表达式模块 ...
- Minieye杯第十五届华中科技大学程序设计邀请赛网络赛D Grid(简单构造)
链接:https://ac.nowcoder.com/acm/contest/560/D来源:牛客网 题目描述 Give you a rectangular gird which is h cells ...