五、Docker本地镜像发布到私有库

目录

1、下载镜像Docker Registry

2、运行私有库Registry,相当于本地有个私有的Docker hub

3、演示创建一个新镜像,Ubuntu安装ifconfig命令

4、curl验证私服库上有什么镜像

5、将新镜像修改符合私服规范的tag

6、修改配置文件使之支持http

7、push推送到私服库

8、curl验证私服库上有什么镜像

9、pull到本地运行


1、下载镜像Docker Registry

[root@localhost ~]# docker pull registry
Using default tag: latest
latest: Pulling from library/registry
79e9f2f55bf5: Pull complete 
0d96da54f60b: Pull complete 
5b27040df4a2: Pull complete 
e2ead8259a04: Pull complete 
3790aef225b9: Pull complete 
Digest: sha256:169211e20e2f2d5d115674681eb79d21a217b296b43374b8e39f97fcf866b375
Status: Downloaded newer image for registry:latest
docker.io/library/registry:latest
[root@localhost ~]# 
[root@localhost ~]# docker images
REPOSITORY                                                 TAG       IMAGE ID       CREATED        SIZE
registry.cn-hangzhou.aliyuncs.com/wuzhaobo_test/myubuntu   1.1       a32a52da6413   26 hours ago   177MB
registry                                                   latest    b8604a3fe854   2 years ago    26.2MB

2、运行私有库Registry,相当于本地有个私有的Docker hub

命令:
-v 宿主机的路径:容器内的路径
[root@localhost usr]# docker run -d -p 5000:5000 -v /usr/myregistry/:/tmp/registry --privileged=true registry
017625b728228dffc240388e0728a969e20be0f0ebf098cc5b8ccc1af4de55bb
[root@localhost usr]# 
[root@localhost usr]# docker ps
CONTAINER ID   IMAGE      COMMAND                  CREATED         STATUS         PORTS                                       NAMES
017625b72822   registry   "/entrypoint.sh /etc…"   6 seconds ago   Up 5 seconds   0.0.0.0:5000->5000/tcp, :::5000->5000/tcp   boring_hopper
[root@localhost usr]# 

3、演示创建一个新镜像,Ubuntu安装ifconfig命令

启动一个镜像,这个ubuntu,是不具备vim命令的,最初的那个镜像
[root@localhost usr]# docker run -it ubuntu /bin/bash
root@2b0c6f8d15f0:/# vim a.txt
bash: vim: command not found
root@2b0c6f8d15f0:/# 
root@2b0c6f8d15f0:/# ifconfig
bash: ifconfig: command not found
root@2b0c6f8d15f0:/# 
#安装ifconfig
root@2b0c6f8d15f0:/# apt-get update 
root@2b0c6f8d15f0:/# apt-get install net-tools
root@2b0c6f8d15f0:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.3  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:03  txqueuelen 0  (Ethernet)
        RX packets 8475  bytes 32375039 (32.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7578  bytes 414607 (414.6 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@2b0c6f8d15f0:/# 
#commit 成自己的私有镜像
Ctrl+p+q退出
[root@localhost usr]# docker ps
CONTAINER ID   IMAGE      COMMAND                  CREATED         STATUS         PORTS                                       NAMES
2b0c6f8d15f0   ubuntu     "/bin/bash"              6 minutes ago   Up 6 minutes                                               eager_wright
017625b72822   registry   "/entrypoint.sh /etc…"   8 minutes ago   Up 8 minutes   0.0.0.0:5000->5000/tcp, :::5000->5000/tcp   boring_hopper
[root@localhost usr]# 
[root@localhost usr]# docker commit -m="add ifconfig cmd" -a="wu" 2b0c6f8d15f0 wuubuntu:1.2
sha256:21423a381c8c6769e410a20d3cf11d773c1caad29ea1c1ecadb7c6c197033e88
[root@localhost usr]# 
[root@localhost usr]# docker images
REPOSITORY                                                 TAG       IMAGE ID       CREATED         SIZE
wuubuntu                                                   1.2       21423a381c8c   4 seconds ago   126MB

#停止原始的镜像
[root@localhost usr]# docker stop 2b0c6f8d15f0
2b0c6f8d15f0
#启动新镜像
[root@localhost usr]# docker run -it 21423a381c8c /bin/bash
root@adc1c0b57a68:/# 
root@adc1c0b57a68:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.3  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:03  txqueuelen 0  (Ethernet)
        RX packets 6  bytes 508 (508.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@adc1c0b57a68:/# 

4、curl验证私服库上有什么镜像

现在有一个新的镜像,有一个私有库在运行,我们要把这个镜像推送到私有库
[root@localhost usr]# docker images
REPOSITORY                                                 TAG       IMAGE ID       CREATED         SIZE
wuubuntu                                                   1.2       21423a381c8c   4 minutes ago   126MB
registry.cn-hangzhou.aliyuncs.com/wuzhaobo_test/myubuntu   1.1       a32a52da6413   26 hours ago    177MB
wu/ubuntu                                                  latest    9fd000d64b52   2 days ago      72.8MB
redis                                                      latest    7614ae9453d1   2 years ago     113MB
registry                                                   latest    b8604a3fe854   2 years ago     26.2MB
ubuntu                                                     latest    ba6acccedd29   2 years ago     72.8MB
hello-world                                                latest    feb5d9fea6a5   2 years ago     13.3kB
[root@localhost usr]# 
先验证私有库是否有其他镜像
[root@localhost usr]# curl -XGET http://192.168.153.128:5000/v2/_catalog
{"repositories":[]}  #为空,表示没有
[root@localhost usr]# 

5、将新镜像修改符合私服规范的tag

公式:
docker tag 镜像:Tag Host:port/Repository:Tag

使用命令 docker tag 将wuubuntu:1.2这个镜像修改为192.168.153.128:5000/wuubuntu:1.2
[root@localhost usr]# docker tag wuubuntu:1.2 192.168.153.128:5000/wuubuntu:1.2
[root@localhost usr]# 
[root@localhost usr]# docker images
REPOSITORY                                      TAG       IMAGE ID       CREATED          SIZE
192.168.153.128:5000/wuubuntu                   1.2       21423a381c8c   13 minutes ago   126MB
wuubuntu                                        1.2       21423a381c8c   13 minutes ago   126MB

#可以看到已经成功了,wuubuntu 为本地的镜像,192.168.153.128:5000/wuubuntu为传到私服库的镜像,所以需要按照私服库的规范来。

6、修改配置文件使之支持http

由于docker 有安全加固,默认是不支持http方式推送镜像的,所以需要做一个配置,取消限制
[root@localhost usr]# cat /etc/docker/daemon.json 
{
  "registry-mirrors": ["https://t2exmlj4.mirror.aliyuncs.com"],
  "insecure-registries": ["192.168.153.128:5000"]
}
[root@localhost usr]# 
添加:"insecure-registries": ["192.168.153.128:5000"]
注意:这是JSON格式,两个配置中间有逗号
修改完如果不生效,建议重启docker

7、push推送到私服库

[root@localhost usr]# docker push 192.168.153.128:5000/wuubuntu:1.2
The push refers to repository [192.168.153.128:5000/wuubuntu]
a7d9a2b2f1ad: Pushed 
9f54eef41275: Pushed 
1.2: digest: sha256:e248a868f5367e4416b1e609bf46b2d01a241758488d6abc467cc0dfeb782a48 size: 741
[root@localhost usr]# 

8、curl验证私服库上有什么镜像

[root@localhost usr]# curl -XGET http://192.168.153.128:5000/v2/_catalog
{"repositories":["wuubuntu"]}
[root@localhost usr]# 

9、pull到本地运行

[root@localhost usr]# docker images
REPOSITORY                                                 TAG       IMAGE ID       CREATED          SIZE
192.168.153.128:5000/wuubuntu                              1.2       21423a381c8c   25 minutes ago   126MB
wuubuntu                                                   1.2       21423a381c8c   25 minutes ago   126MB
registry.cn-hangzhou.aliyuncs.com/wuzhaobo_test/myubuntu   1.1       a32a52da6413   26 hours ago     177MB
wu/ubuntu                                                  latest    9fd000d64b52   2 days ago       72.8MB
redis                                                      latest    7614ae9453d1   2 years ago      113MB
registry                                                   latest    b8604a3fe854   2 years ago      26.2MB
ubuntu                                                     latest    ba6acccedd29   2 years ago      72.8MB

[root@localhost usr]# 
[root@localhost usr]# docker rmi -f 192.168.153.128:5000/wuubuntu:1.2
Untagged: 192.168.153.128:5000/wuubuntu:1.2
Untagged: 192.168.153.128:5000/wuubuntu@sha256:e248a868f5367e4416b1e609bf46b2d01a241758488d6abc467cc0dfeb782a48
[root@localhost usr]# 
[root@localhost usr]# docker images
REPOSITORY                                                 TAG       IMAGE ID       CREATED          SIZE
wuubuntu                                                   1.2       21423a381c8c   26 minutes ago   126MB
registry.cn-hangzhou.aliyuncs.com/wuzhaobo_test/myubuntu   1.1       a32a52da6413   26 hours ago     177MB
wu/ubuntu                                                  latest    9fd000d64b52   2 days ago       72.8MB
redis                                                      latest    7614ae9453d1   2 years ago      113MB
registry                                                   latest    b8604a3fe854   2 years ago      26.2MB
ubuntu                                                     latest    ba6acccedd29   2 years ago      72.8MB
[root@localhost usr]# 
[root@localhost usr]# docker rmi -f wuubuntu:1.2
Untagged: wuubuntu:1.2
Deleted: sha256:21423a381c8c6769e410a20d3cf11d773c1caad29ea1c1ecadb7c6c197033e88
Deleted: sha256:ef4795b52a13423fe8fa35cd9ec3f2ec4977474cda1d12279ae70af25d097b59
[root@localhost usr]# 
[root@localhost usr]# docker images
REPOSITORY                                                 TAG       IMAGE ID       CREATED        SIZE
registry.cn-hangzhou.aliyuncs.com/wuzhaobo_test/myubuntu   1.1       a32a52da6413   26 hours ago   177MB
wu/ubuntu                                                  latest    9fd000d64b52   2 days ago     72.8MB
redis                                                      latest    7614ae9453d1   2 years ago    113MB
registry                                                   latest    b8604a3fe854   2 years ago    26.2MB
ubuntu                                                     latest    ba6acccedd29   2 years ago    72.8MB
[root@localhost usr]# 
[root@localhost usr]# curl -XGET http://192.168.153.128:5000/v2/_catalog
{"repositories":["wuubuntu"]}
[root@localhost usr]# 

[root@localhost usr]# docker pull 192.168.153.128:5000/wuubuntu:1.2
1.2: Pulling from wuubuntu
7b1a6ab2e44d: Already exists 
f224faf5dd6c: Pull complete 
Digest: sha256:e248a868f5367e4416b1e609bf46b2d01a241758488d6abc467cc0dfeb782a48
Status: Downloaded newer image for 192.168.153.128:5000/wuubuntu:1.2
192.168.153.128:5000/wuubuntu:1.2
[root@localhost usr]# 
[root@localhost usr]# docker images
REPOSITORY                                                 TAG       IMAGE ID       CREATED          SIZE
192.168.153.128:5000/wuubuntu                              1.2       21423a381c8c   29 minutes ago   126MB
registry.cn-hangzhou.aliyuncs.com/wuzhaobo_test/myubuntu   1.1       a32a52da6413   26 hours ago     177MB
wu/ubuntu                                                  latest    9fd000d64b52   2 days ago       72.8MB
redis                                                      latest    7614ae9453d1   2 years ago      113MB
registry                                                   latest    b8604a3fe854   2 years ago      26.2MB
ubuntu                                                     latest    ba6acccedd29   2 years ago      72.8MB
[root@localhost usr]# 
[root@localhost usr]# docker run -it 192.168.153.128:5000/wuubuntu:1.2 /bin/bash
root@d4a076e9949e:/# 
root@d4a076e9949e:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.3  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:03  txqueuelen 0  (Ethernet)
        RX packets 7  bytes 578 (578.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@d4a076e9949e:/# 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/767560.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【SOLID原则前端中的应用】开闭原则(Open/Closed Principle)- vue3示例

开闭原则&#xff08;Open/Closed Principle&#xff09;在Vue 3中的应用 开闭原则&#xff08;Open/Closed Principle&#xff0c;OCP&#xff09;规定&#xff0c;软件实体&#xff08;类、模块、函数等&#xff09;应该对扩展开放&#xff0c;对修改关闭。 也就是说&#xf…

中国植物志(80卷)

中国植物志&#xff0c;全书共80卷126分册&#xff0c;3700页&#xff0c;记载了我国301科3408属31142种植物学名、形态特征、生态环境、地理分布、经济用途和物候期等。是研究中国植物的重要论著&#xff08;截图仅部分&#xff09;。

VBA通过Range对象实现Excel的数据写入

前言 本节会介绍通过VBA中的Range对象&#xff0c;来实现Excel表格中的单元格写入、区域范围写入&#xff0c;当然也可以写入不同类型的数据&#xff0c;如数值、文本、公式&#xff0c;以及实现公式下拉自动填充的功能。 一、单元格输入数据 1.通过Value方法实现输入不同类型…

【Python】从文本字符串中提取数字、电话号码、日期、网址的方法汇总(全!)

我们在做数据清洗的时候&#xff0c;有时候会遇到将一堆文本中提取我们需要的内容&#xff0c;最常见的是&#xff0c;从一大段文本中提取出数字、电话号码、日期、网址等。而在Python中&#xff0c;正则表达式re&#xff0c;则可以满足我们从文本中提取数字、电话号码和日期等…

echarts实现3D柱状图(视觉层面)

一、第一种效果 效果图 使用步骤 完整实例&#xff0c;copy就可直接使用 <template><div :class"className" :style"{height:height,width:width}" /> </template><script>import echarts from echartsrequire(echarts/theme/…

《人人都是产品经理》:大产品

《人人都是产品经理》&#xff1a;大产品 产品之大时间之大空间之大&#xff1a;商业、产品、技术设计之大以写书为例 团队之大 回答一个问题 产品经理应该是管理者嘛&#xff1f;优点在于&#xff1a;缺点在于&#xff1a;总结&#xff1a; 如何让团队更加开心总结 产品之大 …

ChatGPT如何应用在谷歌seo?

ChatGPT在提升博客和创作效率方面非常有用。它可以帮助你快速生成吸引人的标题&#xff0c;确保内容第一眼就能抓住读者的注意力。不仅如此&#xff0c;ChatGPT还能根据你的主题生成详细的文章提纲&#xff0c;让你在写作时思路更加清晰。关键词优化也是它的强项&#xff0c;可…

hive内置函数

--查询hive的内置函数列表 show functions; --查询具体函数的使用描述 desc function extended 函数名 desc function extended current_database; 一.字符串函数 1.字符串的拆分 &#xff1a;split(); select split(hello,java;hi,bigdata,[,;]); [ ]内可以写多个分隔符 --…

【论文解读】Multiagent Multitraversal Multimodal Self-Driving: Open MARS Dataset

Open MARS Dataset 摘要引言Dataset CurationVehicle SetupData CollectionDataset Statistics Benchmark Task and ModelPlace RecognitionNeural Reconstruction Experimental ResultsVisual Place RecognitionNeural Reconstruction Opportunities and Challenges结论 摘要 …

7.2、指针变量的定义和使用

代码 #include <iostream> using namespace std; #include <string>int main() {//定义指针int a 10;//指针定义语法&#xff1a;数据类型 * 指针变量名int * p;//让指针记录变量a的地址p &a;cout << "a的地址为&#xff1a;" << &am…

恶意软件是什么意思?常见的恶意软件类型

您可能听说过很多有关恶意软件感染和运行服务器的危险的信息。但是&#xff0c;您可能还不清楚这在现实生活中意味着什么&#xff0c;或者该如何处理。让我们来了解一下&#xff1a;当人们谈论恶意软件时&#xff0c;他们真正指的是什么&#xff1f; 恶意软件是恶意软件的缩写&…

热网无线监测系统 SystemManager.asmx SQL注入漏洞复现

0x01 产品简介 热网无线监测系统是一种先进的热力管网监测解决方案,它通过无线通信技术实现对热力管网各项参数的实时监测和数据分析,以提高供热效率、降低能耗、保障管网安全。系统利用先进的传感器技术和无线通信技术,对热力管网中的温度、压力、流量等关键参数进行实时监…

【JAVA多线程】JDK中的各种锁,看这一篇就够了

目录 1.概论 1.1.实现锁的要素 1.2.阻塞队列 1.3.Lock接口和Sync类 2.各种锁 2.1.互斥锁 2.1.1.概论 2.1.2.源码 1.lock() 2.unlock() 2.2.读写锁 2.3.Condition 2.3.1.概论 2.3.2.底层实现 1.概论 1.1.实现锁的要素 JAVA中的锁都是可重入的锁&#xff0c;因为…

Google 发布了最新的开源大模型 Gemma 2,本地快速部署和体验

Gemma 2 是 Google 最新发布的开源大语言模型。它有两种规模&#xff1a;90 亿&#xff08;9B&#xff09;参数和 270 亿&#xff08;27B&#xff09;参数&#xff0c;分别具有基础&#xff08;预训练&#xff09;和指令调优版本&#xff0c;拥有 8K Tokens 的上下文长度&#…

Akamai+Noname强强联合 | API安全再加强

最近&#xff0c;Akamai正式完成了对Noname Security的收购。本文我们将向大家介绍&#xff0c;经过本次收购后&#xff0c;Akamai在保护API安全性方面的后续计划和未来愿景。 Noname Security是市场上领先的API安全供应商之一&#xff0c;此次收购将让Akamai能更好地满足日益增…

【C语言】extern 关键字

在C语言中&#xff0c;extern关键字用于声明一个变量或函数是定义在另一个文件中的。它使得在多个文件之间共享变量或函数成为可能。extern关键字常见于大型项目中&#xff0c;通常用于声明全局变量或函数&#xff0c;这些变量或函数的定义位于其他文件中。 基本用法 变量声明…

智能语音门锁:置入NV170D语音芯片ic 打造便捷生活新体验

一、智能门锁语音芯片开发背景 随着科技的飞速发展&#xff0c;传统门锁的局限性日益凸显&#xff0c;无法满足现代人对高效、安全生活的需求。在这样的时代背景下&#xff0c;智能门锁应运而生&#xff0c;它不仅继承了传统门锁的基本功能&#xff0c;更通过融入先进的科技元素…

YOLOv8改进 | 卷积模块 | SAConv可切换空洞卷积

秋招面试专栏推荐 &#xff1a;深度学习算法工程师面试问题总结【百面算法工程师】——点击即可跳转 &#x1f4a1;&#x1f4a1;&#x1f4a1;本专栏所有程序均经过测试&#xff0c;可成功执行&#x1f4a1;&#x1f4a1;&#x1f4a1; 专栏目录 &#xff1a;《YOLOv8改进有效…

市场规模5万亿,护理员缺口550万,商业护理企业如何解决服务供给难题?

干货抢先看 1. 据统计&#xff0c;我国失能、半失能老人数量约4400万&#xff0c;商业护理服务市场规模达5万亿。然而&#xff0c;当前养老护理员缺口巨大&#xff0c;人员的供需不匹配是很多养老服务企业需要克服的难题。 2. 当前居家护理服务的主要市场参与者分为两类&…