IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 系统运维 -> Docker-搭建私有仓库 -> 正文阅读

[系统运维]Docker-搭建私有仓库

通常我们在docker拉取的镜像都是在docker hubquay.io等公有仓库获取,那么在实际工作中,每个公司如果使用到docker,那么肯定是要搭建自己的私有仓库。那么接下来就通过docker提供的registry镜像来搭建我们自己的私有仓库。

1、拉取registry镜像

这里默认拉取最新版本,不指定版本就默认拉取latest版本

docker pull registry
Using default tag: latest
latest: Pulling from library/registry
ddad3d7c1e96: Downloading 
6eda6749503f: Download complete 
363ab70c2143: Download complete 
5b94580856e6: Download complete 
12008541203a: Download complete 
latest: Pulling from library/registry
ddad3d7c1e96: Pull complete 
6eda6749503f: Pull complete 
363ab70c2143: Pull complete 
5b94580856e6: Pull complete 
12008541203a: Pull complete 
Digest: sha256:121baf25069a56749f249819e36b386d655ba67116d9c1c6c8594061852de4da
Status: Downloaded newer image for registry:latest
docker.io/library/registry:latest

使用镜像查看命令,查看镜像

docker images registry
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
registry     latest    1fd8e1b0bb7e   3 months ago   26.2MB

2、运行registry镜像

docker run -d -p 5000:5000 --name registry registry:latest 
795e0a78aea0bf39ea95f800221f26fb4882efd4c4dc2143f90b37ee10da3126

查看容器是否启动成功

docker ps
CONTAINER ID   IMAGE             COMMAND                  CREATED          STATUS          PORTS                                       NAMES
795e0a78aea0   registry:latest   "/entrypoint.sh /etc…"   43 seconds ago   Up 42 seconds   0.0.0.0:5000->5000/tcp, :::5000->5000/tcp   registry

查看私有仓库

curl -XGET http://127.0.0.1:5000/v2/_catalog
{"repositories":[]}

可以看到,目前私有仓库里面为空。

3、向私有仓库推送镜像

docker images
REPOSITORY            TAG       IMAGE ID       CREATED        SIZE
arvin88/tomcat_user   v1        77fc61f55a0c   2 days ago     590MB

现在将镜像arvin88/tomcat_user修改为127.0.0.1:5000/tomcat_user

docker tag arvin88/tomcat_user:v1 127.0.0.1:5000/tomcat_user:v2
[root@localhost docker]# docker images
REPOSITORY                   TAG       IMAGE ID       CREATED        SIZE
127.0.0.1:5000/tomcat_user   v2        77fc61f55a0c   2 days ago     590MB
arvin88/tomcat_user          v1        77fc61f55a0c   2 days ago     590MB

推送到私有仓库。

docker push 127.0.0.1:5000/tomcat_user:v2
The push refers to repository [127.0.0.1:5000/tomcat_user]
fa24164bb3bf: Pushed 
e4457e70997e: Pushed 
ffb06ffdd1e8: Pushed 
b6a3bb3fa031: Pushed 
32fff2065e67: Pushed 
ea822a1a4f9d: Pushed 
fe6a347f93b5: Pushed 
f3d5b8f65132: Pushed 
ad83f0aa5c0a: Pushed 
5a9a65095453: Pushed 
4b0edb23340c: Pushed 
afa3e488a0ee: Pushed 
v2: digest: sha256:8d4ed98df7c6ea9b22e33f61c9fac6020625592d75c42759c640bc8ad2af889e size: 2841

然后再使用curl -XGET http://127.0.0.1:5000/v2/_catalog查看私有仓库。

curl -XGET http://127.0.0.1:5000/v2/_catalog
{"repositories":["tomcat_user"]}

可以看到已经推成功了。

4、从私有仓库拉取镜像

为了测试,先将本地镜像全部删除

docker pull 127.0.0.1:5000/tomcat_user:v2
v2: Pulling from tomcat_user
627b765e08d1: Pull complete 
c040670e5e55: Pull complete 
073a180f4992: Pull complete 
bf76209566d0: Pull complete 
f10db7ba7580: Pull complete 
5e5dee180760: Pull complete 
c26c02f721c2: Pull complete 
d24d42fda432: Pull complete 
20abf5c2533f: Pull complete 
d16e82e0b4a0: Pull complete 
32f2c6ec5ff1: Pull complete 
975419add384: Pull complete 
Digest: sha256:8d4ed98df7c6ea9b22e33f61c9fac6020625592d75c42759c640bc8ad2af889e
Status: Downloaded newer image for 127.0.0.1:5000/tomcat_user:v2
127.0.0.1:5000/tomcat_user:v2

查看本地镜像结果

REPOSITORY                   TAG       IMAGE ID       CREATED        SIZE
127.0.0.1:5000/tomcat_user   v2        77fc61f55a0c   2 days ago     590MB

5、常用API

  • 查看私有仓库:curl -XGET http://127.0.0.1:5000/v2/_catalog
curl -XGET http://127.0.0.1:5000/v2/_catalog
{"repositories":["tomcat_user"]}
  • 查看镜像tag:curl -XGET http://127.0.0.1:5000/v2//tags/list
curl -XGET http://127.0.0.1:5000/v2/tomcat_user/tags/list
{"name":"tomcat_user","tags":["v2"]}

官网还提供了其他API,有兴趣可以查看仓库API

  系统运维 最新文章
配置小型公司网络WLAN基本业务(AC通过三层
如何在交付运维过程中建立风险底线意识,提
快速传输大文件,怎么通过网络传大文件给对
从游戏服务端角度分析移动同步(状态同步)
MySQL使用MyCat实现分库分表
如何用DWDM射频光纤技术实现200公里外的站点
国内顺畅下载k8s.gcr.io的镜像
自动化测试appium
ctfshow ssrf
Linux操作系统学习之实用指令(Centos7/8均
上一篇文章      下一篇文章      查看所有文章
加:2021-08-04 11:37:16  更:2021-08-04 11:38:21 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/9 21:57:19-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码