Nexus Docker 镜像仓库配置
2024-2-17
| 2024-4-11
字数 566阅读时长 2 分钟
type
status
date
slug
summary
tags
category
icon
password
AI summary
Last edited time
Apr 11, 2024 06:56 AM

为什么选 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, 这里用的阿里云镜像
    1. notion image
  1. 添加谷歌镜像的代理 ghcr.io
    1. notion image
  1. 添加微软镜像的代理(playwright-java 的 docker 镜像在这)
    1. notion image
  1. 添加自建仓库
    1. notion image
  1. 再搞一个聚合的仓库, 用来对自己提供镜像缓存, 6000 端口用来单独配置反向代理
    1. notion image

nginx 反向代理配置

docker-mirror.sephy.io → nexus:6000 端口
docker-registry.sephy.io → nexus:6001 端口
因为频繁的遇到 docker pull 时都通过 https 方式从 docker-registry.sephy.io 获取镜像, 这里还通过 Fishdrowned 的
ssl
FishdrownedUpdated Apr 10, 2024
项目来生成了自签的证书来配置 nginx https://docker-registry.sephy.io

汇总如下

仓库
repository 类型
代理目标
http 端口
域名
docker-hub
proxy
阿里云公共镜像
docker-ghcr
proxy
谷歌镜像
docker-mcr
proxy
微软镜像
docker-self
hosted
自建镜像
6001
docker-registry.sephy.io
docker-public
group
聚合镜像
6000
docker-mirror.sephy.io

docker 配置

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

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

效果展示

聚合的 docker-public 库
notion image
ghcr 缓存
notion image
微软缓存
notion image
阿里云镜像缓存
notion image
自建私服缓存
notion image

📎 参考文章

 
  • Docker
  • 科学上网阿里云 SLS 日志接入配置
    Loading...