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 <

四、设置开机自启动

[root@qijing0 /]# cat > /usr/lib/systemd/system/registryd.service <
  • 写入 /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,开始享受内网的超高速推送、拉取镜像

版权声明:
作者:主机优惠
链接:https://www.techfm.club/p/45768.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>