500.【registry】 搭建docker私有仓库

一、下载 registry 压缩包

wget https://github.com/distribution/distribution/releases/download/v2.8.1/registry_2.8.1_linux_amd64.tar.gz

二、解压 registry 压缩包,并复制到 /usr/bin/ 目录下

[root@qijing0 workspace_registry]# tar -zxvf registry_2.8.1_linux_amd64.tar.gz 
LICENSE
README.md
registry
mv registry /usr/bin/

三、创建配置文件

[root@qijing0 workspace_registry]# mkdir -p /etc/docker/registry

[root@qijing0 workspace_registry]# cat> /etc/docker/registry/config.yml <<EOF
version: 0.1
log:
  fields:
    service: registry
storage:
  cache:
    blobdescriptor: inmemory
  filesystem:
    rootdirectory: /var/lib/registry
http:
  addr: :5000
  headers:
    X-Content-Type-Options: [nosniff]
health:
  storagedriver:
    enabled: true
    interval: 10s
    threshold: 3
EOF

四、设置开机自启动

[root@qijing0 /]# cat > /usr/lib/systemd/system/registryd.service <<EOF
[Unit]
Description=private registry 
Documentation=https://github.com/distribution/distribution#readme

[Service]
ExecStart=/usr/bin/registry serve /etc/docker/registry/config.yml
User=root
Restart=on-failure
RestartSec=1500ms

[Install]
WantedBy=multi-user.target
EOF
  • 写入 /usr/lib/systemd/system/registryd.service 文件
[root@qijing0 workspace_registry]# systemctl restart registryd && systemctl enable registryd
  • 开机自动启动
[root@qijing0 workspace_registry]# systemctl status registryd
● registryd.service - private registry
   Loaded: loaded (/usr/lib/systemd/system/registryd.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2022-11-21 21:11:30 EST; 1min 39s ago
     Docs: https://github.com/distribution/distribution#readme
 Main PID: 23538 (registry)
    Tasks: 10
   Memory: 12.3M
   CGroup: /system.slice/registryd.service
           └─23538 /usr/bin/registry serve /etc/docker/registry/config.yml

Nov 21 21:11:30 qijing0 systemd[1]: Started private registry.
Nov 21 21:11:30 qijing0 registry[23538]: time="2022-11-21T21:11:30.520567702-05:00" level=warning msg="No HTTP secret provided - generate...
Nov 21 21:11:30 qijing0 registry[23538]: time="2022-11-21T21:11:30.520753886-05:00" level=info msg="redis not configured" go.versi...nknown"
Nov 21 21:11:30 qijing0 registry[23538]: time="2022-11-21T21:11:30.52077835-05:00" level=info msg="Starting upload purge in 9m0s" ...nknown"
Nov 21 21:11:30 qijing0 registry[23538]: time="2022-11-21T21:11:30.536508757-05:00" level=info msg="using inmemory blob descriptor...nknown"
Nov 21 21:11:30 qijing0 registry[23538]: time="2022-11-21T21:11:30.536798348-05:00" level=info msg="listening on [::]:5000" go.ver...nknown"
Hint: Some lines were ellipsized, use -l to show in full
  • 验证服务状态

五、安装用户界面

用户界面比较无所谓,自我感觉不用仔细配置(毕竟不关心界面的技术栈),二进制装还比较麻烦。直接使用docker 启动了:

[root@qijing0 ~]# docker run -d -p 5001:80 --env REGISTRY_TITLE='QIJING Private Docker Registry' --env REGISTRY_URL=http://192.168.3.1:5000 --env SINGLE_REGISTRY=true --name docker-registry-ui joxit/docker-registry-ui:latest          
bb8636f234642068b9e24ee4a92538f1639692d7739994b04ffe06768da7cbb0

浏览器访问ip地址,验证安装:


推送镜像,验证安装:

nerdctl push 192.168.3.1:5000/test-server:0.0.3 --insecure-registry
  • 可以看到,现在已经推送成功了。

拉取镜像,验证安装:

[root@k8s1 ~]# nerdctl pull xxxxxxxxxxxxxxxxx:5000/test-server:0.0.3 --insecure-registry 
WARN[0000] skipping verifying HTTPS certs for "xxxxxxxxxxxxxxxxx:5000" 
INFO[0000] trying next host                              error="failed to do request: Head \"https://xxxxxxxxxxxxxxxxx:5000/v2/test-server/manifests/0.0.3\": http: server gave HTTP response to HTTPS client" host="xxxxxxxxxxxxxxxxx:5000"
WARN[0000] server "xxxxxxxxxxxxxxxxx:5000" does not seem to support HTTPS, falling back to plain HTTP  error="failed to resolve reference \"xxxxxxxxxxxxxxxxx:5000/test-server:0.0.3\": failed to do request: Head \"https://xxxxxxxxxxxxxxxxx:5000/v2/test-server/manifests/0.0.3\": http: server gave HTTP response to HTTPS client"
xxxxxxxxxxxxxxxxx:5000/test-server:0.0.3: resolving      |--------------------------------------| 
elapsed: 0.1 s                                      total:   0.0 B (0.0 B/s)                                         
xxxxxxxxxxxxxxxxx:5000/test-server:0.0.3:                               resolved       |++++++++++++++++++++++++++++++++++++++| 
manifest-sha256:e0f152bb79f22dcbaaf4429cf8bc3cff75d831a5bee8042acf018560f5900586: done           |++++++++++++++++++++++++++++++++++++++| 
config-sha256:cf3c9b089da1f8120c9ee912752dd14d56d7ef769d81d6a81423dea7324a3e5b:   done           |++++++++++++++++++++++++++++++++++++++| 
layer-sha256:1ac10fb9def776a83d1c0f223a554096276d41f7f92ddb642049b8274713c863:    done           |++++++++++++++++++++++++++++++++++++++| 
layer-sha256:58c4eaffce77ac1fb013bf82c91927c631802ad54465ebc9b687b5dc8ee73c02:    done           |++++++++++++++++++++++++++++++++++++++| 
layer-sha256:d14afce733284f533ef0231bbf5eac60b0fe3ea5b536fb62f27d5ed8a66cdcbf:    done           |++++++++++++++++++++++++++++++++++++++| 
layer-sha256:e6a22c806ee8aa2b360bd5818a4f78bc3da280abb86f3db09805b1daddd78324:    done           |++++++++++++++++++++++++++++++++++++++| 
layer-sha256:961d55d95b310f4184745eb0f3dcaad3d03e8d6d477a0ecac1ef4a4b8795ad72:    done           |++++++++++++++++++++++++++++++++++++++| 
layer-sha256:e88a2a8ed0885e3915c290365e61db3b4b2090edf20e0c45980bf1e45d7d991f:    done           |++++++++++++++++++++++++++++++++++++++| 
elapsed: 16.8s                                                                    total:  580.3  (34.5 MiB/s)                                      
[root@k8s1 ~]# nerdctl image ls | grep server
xxxxxxxxxxxxxxxxx:5000/test-server    0.0.3    e0f152bb79f2    2 minutes ago    linux/amd64    845.2 MiB    580.3 MiB
  • 可以看到也是没问题的。

ok,开始享受内网的超高速推送、拉取镜像

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,547评论 6 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,399评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,428评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,599评论 1 274
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,612评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,577评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,941评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,603评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,852评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,605评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,693评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,375评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,955评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,936评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,172评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,970评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,414评论 2 342

推荐阅读更多精彩内容