You Already Run the Registry. You Just Haven’t Turned It On
You self-host Forgejo for your git repos. Then you want a private Docker registry, so you read about Harbor. Then you want private npm packages, so you read about Verdaccio. Now your plan is three stacks, three databases, and three sets of credentials, to host a few dozen images and four internal libraries.
Skip that. Forgejo has a built-in package registry that speaks the OCI container protocol and the npm protocol, and it supports more than 20 other formats too. It runs inside the Forgejo process you already back up and already put behind a reverse proxy. For a home lab or a small team, it is enough. Harbor and Verdaccio earn their place only when you need specific features, and I will list those near the end.
This post uses Forgejo 17 (the current stable line, 17.0.2, released 2026-11-18) and walks through both registries on one instance.
Full example: Clone the working files at github.com/KingPin/sumguy-examples/self-hosting/forgejo-packages-registry
What Forgejo Packages Actually Gives You
A package belongs to an owner, meaning a user or an organization. You can link a package to a repo afterward so it shows up in the repo’s Packages tab, but the owner still controls access.
Access follows the owner:
| Owner type | Read | Write |
|---|---|---|
| User | Public if the user is public, otherwise that user only | Owner only |
| Organization | Public if the org is public, otherwise org members only | Org members with admin or write access |
Two more rules from the docs. Setting service.REQUIRE_SIGNIN_VIEW locks public access instance-wide. And the docs warn that this permission model may change, with a finer-grained team permission planned. There is no per-image visibility toggle today, so a private image means a private owner.
Practical consequence: if you want a public image and a private image, put them under different owners, for example a public homelab-public org and a private homelab org.
Turning It On
The registry is enabled by default. The [packages] section of app.ini has ENABLED: true out of the box. You only touch config to set limits, and you should, because the defaults are no limits at all (-1).
Here is a compose file with those limits set through environment variables. Forgejo’s Docker image maps FORGEJO__section__KEY to app.ini entries.
services: forgejo: image: codeberg.org/forgejo/forgejo:17 container_name: forgejo restart: always environment: - USER_UID=1000 - USER_GID=1000 - FORGEJO__packages__LIMIT_TOTAL_OWNER_SIZE=20 GiB - FORGEJO__packages__LIMIT_SIZE_CONTAINER=2 GiB - FORGEJO__packages__LIMIT_SIZE_NPM=100 MB volumes: - ./forgejo:/data - /etc/localtime:/etc/localtime:ro ports: - "3000:3000" - "222:22"The same thing in app.ini:
[packages]ENABLED = trueLIMIT_TOTAL_OWNER_SIZE = 20 GiBLIMIT_SIZE_CONTAINER = 2 GiBLIMIT_SIZE_NPM = 100 MBEach key does one job:
LIMIT_TOTAL_OWNER_SIZEcaps all packages for a single owner combined.LIMIT_SIZE_CONTAINERandLIMIT_SIZE_NPMcap a single upload of that type. Formats like1000,1 MB, and1 GiBare accepted.LIMIT_TOTAL_OWNER_COUNTcaps the number of package versions per owner.CHUNKED_UPLOAD_PATH(defaulttmp/package-uploadunder the data path) is where big uploads land while they assemble. Make sure that disk has room for your largest layer.
A runaway CI loop that pushes a 900 MB image on every commit is a real thing that happens. A cap turns it into a failed job instead of a full disk.
The Reverse Proxy Gotcha
Docker pushes upload layers as large request bodies. nginx rejects bodies over 1 MB by default and answers with a 413, which shows up in Docker as a failed layer upload. Forgejo’s own nginx example sets client_max_body_size 512M; inside the location / block. Copy that:
server { listen 443 ssl; server_name forgejo.example.com;
location / { client_max_body_size 512M; proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; }}If one of your layers is bigger than 512 MB (a CUDA base image, say), raise the number.
Container Registry: Login, Tag, Push, Pull
Images are named {registry}/{owner}/{image}:{tag}, where the registry is just the hostname of your Forgejo. Nested names like forgejo.example.com/alice/my/image are valid too.
First, make a token. In your Forgejo user settings, under Applications, create an access token with the write:package scope. The docs say write:package grants read, write, and delete on package operations and is currently the same as read:package. If you use 2FA or OAuth login, you must use a token as the password anyway.
docker login forgejo.example.com# Username: alice# Password: <paste the access token>
docker build -t forgejo.example.com/alice/webapp:1.0 .docker push forgejo.example.com/alice/webapp:1.0
# on any other machinedocker login forgejo.example.comdocker pull forgejo.example.com/alice/webapp:1.0Two quirks worth knowing:
- Tag names are case-insensitive.
webapp:Betaandwebapp:betaare the same tag. - A public owner means anyone can pull without logging in. A private owner means every host that pulls needs a login.
Linking an Image to a Repo
By default the image sits under your user or org page and not in any repo’s Packages tab. Forgejo links an image to a repo automatically on first creation, in two ways. Label the image:
LABEL org.opencontainers.image.source=https://forgejo.example.com/alice/webappOr name the image after the repository, as in forgejo.example.com/alice/webapp. If both match, the label wins. The catch: auto-linking happens only when the package is first created. New tags on an existing image never re-link it. If you missed the window, open the package’s Settings page and pick the repo manually. That links the whole package, not one version.
Building and Pushing From Forgejo Actions
Here is the workflow most people want: push to main, runner builds the image, image lands in your registry. I am using a personal access token stored as a repository secret. The CI example in Forgejo’s npm docs carries a comment telling you not to use the automatic FORGEJO_TOKEN secret and to use the owner’s token instead. The container docs do not make a promise either way about the automatic token, so I do not rely on it and neither should you.
Create a secret named REGISTRY_TOKEN in the repo settings, holding a token with write:package. The job needs a runner with a Docker CLI, such as the ci label from the runner setup post.
name: Build and push image
on: push: branches: [main]
jobs: image: runs-on: ci steps: - uses: actions/checkout@v6
- name: Log in to the Forgejo registry run: | echo "${{ secrets.REGISTRY_TOKEN }}" | \ docker login forgejo.example.com -u alice --password-stdin
- name: Build and push run: | IMAGE=forgejo.example.com/alice/webapp docker build -t "$IMAGE:${{ github.sha }}" -t "$IMAGE:latest" . docker push "$IMAGE:${{ github.sha }}" docker push "$IMAGE:latest"Tagging with the commit SHA gives you a rollback target. latest is for humans.
npm Registry: Private Packages
Now the second half. The registry URL for an owner is https://forgejo.example.com/api/packages/{owner}/npm/. It supports scoped and unscoped packages, and works with npm, yarn, and pnpm.
Use a scope. Point the scope at Forgejo and leave everything else on npmjs. Put this in a project-level .npmrc:
@homelab:registry=https://forgejo.example.com/api/packages/homelab/npm///forgejo.example.com/api/packages/homelab/npm/:_authToken=${FORGEJO_NPM_TOKEN}Look at the second line. It has no https: in front. npm auth entries are keyed by a bare URI fragment, and with the scheme added npm never matches the token to the registry. The Forgejo docs call this out specifically. In my test on npm 11, the https: version made npm publish fail with ENEEDAUTH and a suggestion to run npm adduser, which sends you looking in the wrong place.
Export the token in your shell (a personal access token with write:package, belonging to a user who can write to the homelab org), and keep it out of the committed file:
export FORGEJO_NPM_TOKEN="<your access token>"The package name must carry the scope:
{ "name": "@homelab/utils", "version": "1.0.0", "main": "index.js"}Publish and install:
npm publish
# in another project that has the same .npmrc scope linesnpm install @homelab/utilsA few behaviors that differ from npmjs:
- You cannot publish a name and version that already exists. Delete that version in the UI or with
npm unpublish @homelab/[email protected], and unlike npmjs you can republish the same version right away. If that version is the only one, the npm client refuses the unpublish (it assumes npmjs and its 24-hour republish block) until you add--force. Forgejo has no such block. npm dist-tagworks, but a tag name that parses as a version is rejected.- Supported commands are
install,ci,publish,unpublish,dist-tag,view, andsearch. Search does not support qualifiers likeauthor:.
For CI publishing, the docs example sets npm config set for the scope and token, then runs npm publish --scope=@homelab --registry=..., with the owner’s token in a secret. Same pattern as the image workflow above.
Cleanup Rules, Before the Disk Fills
Registries grow forever unless you stop them. Each owner manages cleanup rules for their own packages: go to the owner’s (user or org) settings and find the package cleanup rules. A rule targets one package type, so you make one rule for Container and one for npm.
The settings:
- Keep the most recent: how many versions to always keep per package.
- Keep versions matching: a regex of versions to protect. An empty pattern protects nothing, and
.+protects everything. - Remove versions older than: only delete versions past this many days.
- Remove versions matching: a regex of versions to delete. An empty pattern or
.+removes everything the other settings do not protect. - Apply pattern to full package name: matches
package/versioninstead of only the version.
Patterns are anchored and case-insensitive. Do not write ^ or $. The container registry always keeps the latest version regardless.
A sane home lab rule for images: keep the 10 most recent, keep versions matching latest|v.+, remove versions older than 30 days. Because every commit-SHA tag you push is a version, this prunes the CI litter while leaving your release tags alone. Use the preview button before you enable it. A rule with a wrong regex and no preview is how you delete a production image on a Friday.
Deleting a version does not free disk immediately. Forgejo deduplicates blobs, and a delete only drops the references. A background cleanup job removes unreferenced blobs after the OLDER_THAN period passes, so your disk usage drops a bit after your rules run, not during.
When Forgejo Packages Is Enough
Stay on Forgejo Packages when:
- You have one instance, one team or household, and under a few hundred GB of artifacts.
- Your needs are push, pull, tag, and delete old stuff.
- You would rather have one thing to back up, patch, and monitor than three.
That covers most home labs. A Harbor install is a forklift: great if you move pallets, silly if you move one couch a year. The Harbor post shows how much stack you sign up for.
When to Reach for Harbor
Move your images to Harbor when you need things I could not find in Forgejo’s package docs:
- Vulnerability scanning with Trivy on push, plus policies that block pulling a vulnerable image.
- Replication to a second registry or site.
- Proxy cache projects that mirror Docker Hub and similar upstreams, so a rate limit does not stall your deploys.
- Robot accounts and RBAC at scale, with scoped credentials per project. Forgejo gives you users, orgs, and tokens, which is fine until you have twenty teams.
Notice that none of these is about pushing and pulling images. If you cannot name one of the four bullets you need, you do not need Harbor yet. Forgejo and Harbor can run side by side, so migrating later is a docker pull and docker push per image.
When to Reach for Verdaccio
Verdaccio’s selling feature is uplinks. You configure it with uplinks: pointing at https://registry.npmjs.org/, and it proxies and caches public packages, so installs work faster and keep working when npmjs hiccups. Forgejo’s npm registry is a place to publish your own packages. It is not a caching proxy for the public registry.
So the split is simple. Private internal packages only: Forgejo. Faster CI installs through a cache of public packages, or one registry URL that serves both: Verdaccio.
Gotchas Worth Writing Down
- Wrong token scope. The login or push is denied and the Docker client prints something unhelpful. Check that the token has
write:packageand that the user can write to the owner. - HTTPS and the proxy body limit. Covered above. If pushing a small image works and a large one fails, it is the body limit.
- Permissions follow the owner. If a CI user cannot push to an org’s package, check org membership and whether the team has write access.
- Backups. Package blobs live on the filesystem and metadata lives in the database. Your normal Forgejo backup covers packages only if it covers both, and Docker images are large, so size your backup target for them.
Common Questions
Does Forgejo have a built-in Docker registry?
Yes. Forgejo includes an OCI-compliant container registry in the same process as git hosting, enabled by default. You log in with docker login forgejo.example.com and push images named forgejo.example.com/{owner}/{image}:{tag}. No extra service is required.
Can I make a single Forgejo image private and others public?
No, not per image. Package access follows the owner: a public user or org exposes its packages publicly, and a private one restricts them. To mix both, put public images under one owner and private images under another, such as two separate organizations. The Forgejo docs note finer-grained team permissions are planned but not available.
Why does docker push fail with a 413 on large images?
The reverse proxy is rejecting the layer upload as too large. nginx limits request bodies to 1 MB unless you raise client_max_body_size. Forgejo’s own nginx example sets 512M inside the location / block. Set it above your biggest layer, reload nginx, and retry the push. Small images succeed while large ones fail, which is the telltale sign. Check the proxy’s error log for the 413 to confirm.
Can I move images from Docker Hub or Gitea to Forgejo?
Yes. For each image, run docker pull from the old registry, docker tag it with the new forgejo.example.com/{owner}/{image}:{tag} name, and docker push it. Nothing converts automatically. A short shell loop over your image list handles dozens of images in minutes.
Do I need Harbor or Verdaccio if I use Forgejo Packages?
Not for a home lab. Forgejo Packages covers push, pull, tags, access control by owner, and cleanup rules for both containers and npm. Add Harbor only for vulnerability scanning, replication, proxy cache, or many scoped robot accounts. Add Verdaccio only when you want a caching proxy for public npm packages. Without one of those needs, the extra stacks are overhead.