docker简单私有仓库的搭建

示例: 【搭建简单的Registry仓库】

  1. 下载 Registry 镜像
    root@docker \~# docker pull registry

    #可以查看开放的端口,需要把端口暴露出来
    root@docker \~# docker history registry:latest

    root@docker \~# docker run -d -p 5000:5000 --restart=always registry
    9f389c98fbd2163fb6487a5bfd2358751eb4ecb07eb47f463ae76f12b117361c
    root@docker \~# docker ps
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    9f389c98fbd2 registry "/entrypoint.sh /etc..." 14 seconds ago Up 12 seconds 0.0.0.0:5000->5000/tcp, :::5000->5000/tcp hardcore_saha
    #推送push #把当前镜像 nginx:v2 推送到 5000 端口
    root@docker \~# docker tag nginx:v2 172.25.254.5:5000/nginx.v3
    root@docker \~# docker push 172.25.254.5:5000/nginx.v3
    Using default tag: latest
    The push refers to repository 172.25.254.5:5000/nginx.v3
    Get "https://172.25.254.5:5000/v2/": http: server gave HTTP response to HTTPS client

默认用 https 的方式:得做认证

root@docker \~#
#也可以不用https,而用http的方式,必须得配置非加密端口信息。/etc/docker/daemon.json
root@docker \~# vim /etc/docker/daemon.json
root@docker \~# cat /etc/docker/daemon.json
{
"insecure-registries" : "http://172.25.254.5:5000"
}
root@docker \~# systemctl restart docker
root@docker \~# docker push 172.25.254.5:5000/nginx.v3
Using default tag: latest
The push refers to repository 172.25.254.5:5000/nginx.v3
54a2c5fcea1c: Pushed
a8df99e45168: Pushed
174f56854903: Pushed
latest: digest: sha256:2d45824da0f28c4087c7a2c009cc4dba14efc637fdd8bef91fd49a1dcbda8b8c size: 947

推上去的数据在哪?

root@docker \~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9f389c98fbd2 registry "/entrypoint.sh /etc..." 13 minutes ago Up 4 minutes 0.0.0.0:5000->5000/tcp, :::5000->5000/tcp hardcore_saha
root@docker \~# docker inspect hardcore_saha
真机中位于:

最终数据位于容器的:

进去真机中的路径下看看,有 nginx:v3

root@docker \~# cd /var/lib/docker/volumes/fbc4139d10af9999ee19f7856fb7b5d187337af25eb9c927ef0e99eff304f0f0/_data
root@docker _data# ls
docker
root@docker _data# cd docker/
root@docker docker# cd registry/
root@docker registry# ls
v2
root@docker registry# cd v2/
root@docker v2# ls
blobs repositories
root@docker v2# cd repositories/
root@docker repositories# l
bash: l: command not found...
root@docker repositories# ls
nginx.v3

root@docker \~# curl 172.25.254.5:5000/v2/_catalog
{"repositories":"nginx.v3"}

再推一个试试:

root@docker \~# docker tag busybox:latest 172.25.254.5:5000/busybox:xixi
root@docker \~# docker push 172.25.254.5:5000/busybox:xixi
The push refers to repository 172.25.254.5:5000/busybox
d51af96cf93e: Pushed
xixi: digest: sha256:28e01ab32c9dbcbaae96cf0d5b472f22e231d9e603811857b295e61197e40a9b size: 527

相关推荐
xier_ran9 分钟前
【infra之路】模块三:Kubernetes (上) — 概念、集群搭建、Pod 与 Deployment
云原生·容器·kubernetes
原来是猿9 分钟前
性能测试(1)
运维·服务器·python·压力测试
IT策士11 分钟前
第 23篇 k8s之Pod:多容器 Pod 与设计模式(Sidecar 等)
设计模式·容器·kubernetes
ai产品老杨16 分钟前
解耦视频流利器:如何利用 GB28181 与 RTSP 协议统一收敛多厂商设备?一套支持 Docker 部署与源码交付的边缘计算 AI 视频中台深度解析
人工智能·docker·边缘计算
为思念酝酿的痛9 小时前
POSIX信号量
linux·运维·服务器·后端
专业白嫖怪9 小时前
什么是docker
运维·docker·容器
人还是要有梦想的10 小时前
linux下用搜狗输入法,中英文切换
linux·运维·服务器
北京智和信通10 小时前
某部队IT基础设施及机房动环统一运维建设实例
运维·网管平台·网管软件·网络管理系统·网络运维平台·网络运维系统
乐维_lwops10 小时前
从 “救火运维” 到 “自动驾驶”:运维智能体到底解决了什么?
运维·人工智能·运维智能体
bush410 小时前
嵌入式linux学习记录二
linux·运维·学习