Show HN:自托管的 Docker 镜像仓库。一个容器,两个简单的账号
Show HN: Self-hosted Docker image registry. One container, two simple accounts

原始链接: https://github.com/dellarb/registreasy

Registreasy 是一个简单的 Docker 镜像仓库,基于 Nginx 后的 CNCF Distribution 构建,使用一个容器、一个端口,并将 `./data` 作为唯一的持久化数据目录;请将 `./data` 连同部署配置和凭据一起备份。它恰好支持两个用户:`push`(读取、发布、通过 Web UI 删除标签)和 `pull`(只读;不设置 `PULL_PASSWORD` 可允许匿名拉取)。Web 清单按仓库列出带标签的镜像,预览删除操作,并允许 `push` 用户执行在线删除或安排/运行离线垃圾回收。 使用 `docker-compose.yml` 部署,镜像为 `ghcr.io/dellarb/registreasy:latest`,设置强且各不相同的 `PUSH_PASSWORD` 和可选的 `PULL_PASSWORD`。默认绑定为 `127.0.0.1:5000`;如需 LAN/VPN 访问,请设置 `BIND_ADDRESS` 和 `PORT`,并为 Docker 配置 `insecure-registries` 以使用明文 HTTP。如需公开访问,请使用 TLS 代理、本地绑定,并设置 `REQUIRE_HTTPS=1` 和 `TRUSTED_PROXY`。 标准 `docker login/push/pull` 可用,但 Docker 每个主机只保存一个登录凭据,因此请按需切换账号。遥测是可选的、假名化的,并且默认关闭。支持从源码构建;项目采用 AGPL-3.0 许可证。

一篇 Hacker News 的 Show HN 帖子介绍了 Registreasy,这是一个主打简洁的自托管 Docker 镜像仓库。作者 dellarb 想要一种简单的方法,可以私下推送镜像并从其他主机拉取,而不必直接使用命令行工具、复杂配置文件或笨重的权限系统。Registreasy 以单个容器运行,并通过 Docker Compose 配置两个密码:一个用于可推送的账户,另一个用于只读拉取的账户。用户也可以按需允许匿名拉取。一位评论者拿这个名字开玩笑(“Registryeezy”),并表示这个项目看起来很有用,打算试试。
相关文章

原文
  • One container, one port, one data folder. Back up ./data and keep your deployment configuration and credentials with it.
  • Simple users that match how you work. Two accounts, and exactly that much.
  • See what you have. A web page lists tagged images by repository and previews deletes before you confirm.
Account Can do
🔑 push Read images, publish images, delete tags in the web page
👀 pull Read images only. Leave PULL_PASSWORD unset to skip it and allow anonymous pulls

Built on the CNCF Distribution registry behind Nginx. Works with plain docker login, push, pull and Compose.

docker-compose.yml:

services:
  registreasy:
    image: ghcr.io/dellarb/registreasy:latest
    restart: unless-stopped
    ports:
      - "${BIND_ADDRESS:-127.0.0.1}:${PORT:-5000}:5000"
    environment:
      PUSH_PASSWORD: "replace-with-a-long-random-push-password"
      PULL_PASSWORD: "replace-with-a-long-random-pull-password"   # omit to allow pulls with no password
    volumes:
      - ./data:/data

Replace each example password with a different random secret.

The quick start binds to 127.0.0.1, so only clients on the registry host can connect. For pulls and pushes from another machine on a trusted LAN or VPN, set BIND_ADDRESS in the Compose project's .env to the registry host's LAN or VPN IP (for example, 192.168.1.10) and run docker compose up -d. Set PORT in the same file if you want a host port other than 5000. Use that IP and port on the client. With plain HTTP, add the endpoint to the client's Docker insecure-registries setting and restart Docker. Only the push account can publish.

docker pull alpine:3.22
docker tag alpine:3.22 localhost:5000/example/alpine:demo
docker login localhost:5000 -u push
docker push localhost:5000/example/alpine:demo
docker logout localhost:5000
docker image rm localhost:5000/example/alpine:demo

# Omit this login when PULL_PASSWORD is unset.
docker login localhost:5000 -u pull
docker pull localhost:5000/example/alpine:demo

Docker keeps one login per hostname, so a docker login -u push and a docker login -u pull overwrite each other. Pushing needs the push login; pulling needs whichever account your PULL_PASSWORD setting requires.

Replace localhost:5000 with your host and port. Images are stored under the repository name you choose, here example/alpine.

Open the web inventory http://[yourhost]:5000 and sign in. The pull account provides a read-only view when configured. The push account can preview and confirm tagged-image deletes.

Routine deletes leave the registry online. In Settings, the push user can run offline garbage collection on demand or enable a daily window. See maintenance and recovery for downtime, backups, and rollback. The registry-size card measures the on-disk total automatically when you open the inventory.

Telemetry is optional and off until a signed-in user opts in (banner or Settings → Privacy & Telemetry); there is also a Feedback button. It is pseudonymous installation telemetry: counts and error categories only, never image names, tags or users, and you can preview exactly what each option sends and turn it off at any time. See telemetry, privacy and feedback.

HTTPS. By default, plain HTTP is accepted only from private addresses (loopback, 10/8, 172.16/12, 192.168/16, 169.254/16, 100.64/10 and IPv6 ULA/link-local). Keep plain HTTP on a trusted LAN or VPN. For anything public, put a TLS proxy in front, bind the registry port to loopback, set REQUIRE_HTTPS=1, and point TRUSTED_PROXY at the proxy's IP so the forwarded client address and scheme are trusted. /healthz remains available over plain HTTP for monitors, including when REQUIRE_HTTPS=1.

Pull without a password. Leave PULL_PASSWORD unset or empty. Anyone who reaches the port can pull every image. Writes and the web page still need a sign-in. Use it only on a LAN or VPN, or behind HTTPS with appropriate access controls.

Configuration.

Variable Default Meaning
PUSH_PASSWORD required Push user password
PULL_PASSWORD unset (anonymous pulls) Pull user password; set it to require authenticated pulls
PUSH_USERNAME / PULL_USERNAME push / pull Account names (must differ)
BIND_ADDRESS / PORT 127.0.0.1 / 5000 Compose host bind address and published port
REQUIRE_HTTPS 0 Require HTTPS except for health checks
TRUSTED_PROXY unset IP address of the TLS proxy
TZ UTC Default IANA timezone for scheduled garbage collection; a timezone saved in Settings takes precedence
GC_DRAIN_SECONDS / GC_TIMEOUT_SECONDS 30 / 900 Seconds allowed for each drain wait and for collection, respectively
SESSION_IDLE_SECONDS / SESSION_MAX_SECONDS 1800 / 43200 Web sign-in limits

Build from source. git clone https://github.com/dellarb/registreasy.git, set PUSH_PASSWORD in .env and optionally PULL_PASSWORD to require authenticated pulls, then docker compose up -d --build.

Pull requests welcome; see CONTRIBUTING.md. Report vulnerabilities via SECURITY.md. Licensed under the AGPL-3.0; running the unmodified image has no extra obligations.

联系我们 contact @ memedata.com