Nexus Docker 镜像仓库配置

604 字
3 分钟
Nexus Docker 镜像仓库配置

为什么选 nexus3 不选 harbor#

因为穷, 家里的闲置主机资源配置一般, 已经跑了以下应用

  • PVE(是的, 我在闲置主机上先装了 PVE)
  • 基于 PVE 的 Debian
  • nexus3(对, 就是那个大名鼎鼎的 java maven 自建私服应用)
  • gitea(有些小项目我懒得放 github)
  • mysql8
  • nginx
  • syncthing
  • xxl-job-admin
  • java 爬虫应用

harbor 的组件太多, 我不想再装 postgres 等数据库了(感觉躲不过, 下一步的 sonarqube 好像要用 postgres)

配置说明#

nexus 配置#

以下 repository 配置都不需要勾选启用 v1 的 api

  1. 添加 docker-hub 的 proxy, 这里用的阿里云镜像
    Untitled 75
    Untitled 75
  2. 添加谷歌镜像的代理 ghcr.io
    Untitled 76
    Untitled 76
  3. 添加微软镜像的代理(playwright-java 的 docker 镜像在这)
    Untitled 77
    Untitled 77
  4. 添加自建仓库
    Untitled 78
    Untitled 78
  5. 再搞一个聚合的仓库, 用来对自己提供镜像缓存, 6000 端口用来单独配置反向代理
    Untitled 79
    Untitled 79

nginx 反向代理配置#

docker-mirror.sephy.io → nexus<6000> 端口

docker-registry.sephy.io → nexus<6001> 端口

==因为频繁的遇到 docker pull 时都通过 https 方式从 docker-registry.sephy.io 获取镜像, 这里还通过 Fishdrowned 的 ==== https://github.com/Fishdrowned/ssl ==== 项目来生成了自签的证书来配置 nginx https://docker-registry.sephy.io==

汇总如下#

仓库repository 类型代理目标http 端口域名
docker-hubproxy阿里云公共镜像
docker-ghcrproxy谷歌镜像
docker-mcrproxy微软镜像
docker-selfhosted自建镜像6001docker-registry.sephy.io
docker-publicgroup聚合镜像6000docker-mirror.sephy.io

docker 配置#

/etc/docker/daemon.json

{
"registry-mirrors": ["http://docker-mirror.sephy.io"],
"insecure-registries": ["docker-registry.sephy.io"]
}

改完 daemon.json 后需要重启 docker, 并登录到私有仓库

Terminal window
sudo systemctl daemon-reload
sudo systemctl restart docker
docker login -u admin https://docker-registry.sephy.io

验证一下上传自定义镜像到私服#

Terminal window
# tag 格式 registry/namespace/image-name:version
docker tag maven:3.9.6-eclipse-temurin-21-jammy-custom docker-registry.sephy.io/maven:3.9.6-eclipse-temurin-21-jammy-custom
docker push docker-registry.sephy.io/maven:3.9.6-eclipse-temurin-21-jammy-custom
The push refers to repository [docker-registry.sephy.io/maven]
442fe6ab34d7: Pushed
6d5dc7bd1e8b: Pushed
b87a4be1beb2: Pushed
908af68e2e85: Pushed
c7dab9361ce9: Pushed
a24a61ddf7b4: Pushed
c1793f638462: Pushed
4df676480fd4: Pushed
d9d7e0852802: Pushed
cbb50874016a: Pushed
5498e8c22f69: Pushed
3.9.6-eclipse-temurin-21-jammy-custom: digest: sha256:f0bf790bda0c8d43ac142de4066dc3e7286659ad789762e5ee494ccc712e3483 size: 2624

效果展示#

聚合的 docker-public 库

Untitled 80
Untitled 80

ghcr 缓存

Untitled 81
Untitled 81

微软缓存

Untitled 82
Untitled 82

阿里云镜像缓存

Untitled 83
Untitled 83

自建私服缓存

Untitled 84
Untitled 84

📎 参考文章#

文章分享

如果这篇文章对你有帮助,欢迎分享给更多人!

Nexus Docker 镜像仓库配置
https://blog.sephy.top/posts/nexus-docker-镜像仓库配置/
作者
虾米
发布于
2024-02-17
许可协议
CC BY-NC-SA 4.0
Profile Image of the Author
虾米
coder
分类
标签
站点统计
文章
61
分类
4
标签
52
总字数
64,663
运行时长
0
最后活动
0 天前
站点信息
构建平台
GitHub Actions
博客版本
Firefly v6.13.9
文章许可
CC BY-NC-SA 4.0