Set up a Docker group repository in Nexus
Overview¶
This guide covers setting up Nexus Repository Manager with a Docker Group that combines a private hosted repository and a Docker Hub proxy cache into a single URL.
Final Architecture:
registry.nexus.castis.io (single URL for everything)
│
▼
docker-group (group repo, port 8082)
├── docker-hosted → your private images
└── proxy-dockerhub → cached public images from Docker Hub
Prerequisites¶
- Nexus Repository Manager 3.41.0+
- Domain configured (e.g.
registry.nexus.castis.io) - Reverse proxy (Apisix/Nginx) routing domain to Nexus port 8082
Step 1 — Create Docker Hub Proxy Repository¶
- Go to Administration → Repositories → Create Repository
- Select
docker (proxy) - Configure:
| Field | Value |
|---|---|
| Name | proxy-dockerhub |
| Online | checked |
| HTTP | blank |
| HTTPS | blank |
| Allow anonymous docker pull | checked |
| Remote storage | https://registry-1.docker.io |
| Docker Index | Use Docker Hub |
| Foreign Layer Caching | checked |
| Foreign Layer Allowed URLs | .* |
| Maximum component age | -1 |
| Maximum metadata age | -1 |
| Not found cache TTL | 1440 |
- Click Save
Step 2 — Remove Port from docker-hosted¶
Since docker-group will own port 8082, remove it from docker-hosted:
- Go to Repositories → docker-hosted → Edit
- Set HTTP → uncheck / blank
- Click Save
Step 3 — Create Docker Group Repository¶
- Go to Administration → Repositories → Create Repository
- Select
docker (group) - Configure:
| Field | Value |
|---|---|
| Name | docker-group |
| Online | checked |
| HTTP | 8082 |
| HTTPS | blank |
| Allow anonymous docker pull | checked |
- Member repositories (order matters!):
Members:
1. docker-hosted ← first (private images, higher priority)
2. proxy-dockerhub ← second (public images fallback)
- Click Save
Step 4 — Configure k3s to Use Nexus as Mirror¶
On each k3s node:
mirrors:
docker.io:
endpoint:
- "https://registry.nexus.castis.io"
configs:
"registry.nexus.castis.io":
auth:
username: <NEXUS_USER>
password: <NEXUS_PASSWORD>
How It Works¶
Pull order (docker-group)¶
When pulling an image, Nexus searches members top to bottom:
docker pull registry.nexus.castis.io/playtelly/myapp:latest
1. Check docker-hosted → FOUND serve immediately
docker pull registry.nexus.castis.io/nginx:latest
1. Check docker-hosted → not found
2. Check proxy-dockerhub → fetch from Docker Hub, cache, serve
Proxy Cache benefit¶
First pull: k3s → Nexus → Docker Hub (download + cache)
Second pull: k3s → Nexus → local cache (no internet needed)
Usage¶
Push private image (CI/CD)¶
Pull private image¶
Pull public image (auto cached)¶
k3s deployments (no changes needed)¶
spec:
containers:
- image: nginx:latest # automatically redirected to Nexus
- image: postgres:15 # automatically redirected to Nexus
Multi-Platform Images (ARM64 + AMD64)¶
Build and push multi-platform images via GitLab CI:
.build_template:
stage: build
image: docker:24
services:
- docker:24-dind
script:
- PROJECT_NAME=$(echo $CI_PROJECT_NAME | tr '[:upper:]' '[:lower:]')
- docker login -u $NEXUS_USER -p $NEXUS_PASSWORD $REGISTRY_URL
- docker buildx create --use --name multiarch || true
- |
docker buildx build \
--platform linux/amd64,linux/arm64 \
--cache-from $IMAGE_BASE/$PROJECT_NAME:$ENV_NAME-latest \
--tag $IMAGE_BASE/$PROJECT_NAME:$ENV_NAME-$CI_COMMIT_SHORT_SHA \
--tag $IMAGE_BASE/$PROJECT_NAME:$ENV_NAME-latest \
--push \
.
Verify multi-platform image:
Expected output:
Troubleshooting¶
Platform warning on Apple Silicon¶
WARNING: The requested image's platform (linux/amd64) does not match detected host platform (linux/arm64/v8)
--platform linux/amd64,linux/arm64
Image not found in registry¶
# Verify image exists in Nexus
docker buildx imagetools inspect registry.nexus.castis.io/playtelly/<image>:<tag>
Proxy not caching¶
# Check proxy-dockerhub status in Nexus UI
# Administration → Repositories → proxy-dockerhub → Status should be "Online - Remote Available"
k3s not using Nexus mirror¶
# Verify registries.yaml is correct
sudo cat /etc/rancher/k3s/registries.yaml
# Restart k3s
sudo systemctl restart k3s
# Check k3s logs
sudo journalctl -u k3s -f
Repository Summary¶
| Repo | Type | Port | Purpose |
|---|---|---|---|
docker-hosted |
hosted | none | Store private images |
proxy-dockerhub |
proxy | none | Cache Docker Hub images |
docker-group |
group | 8082 | Single URL for everything |
Benefits¶
| Benefit | Detail |
|---|---|
| Faster deploys | Images served from local network |
| Save bandwidth | Public images downloaded once, cached forever |
| No rate limits | Bypasses Docker Hub 100 pulls/6hr limit |
| Works offline | Internet down? cached images still work |
| Transparent | No changes needed in deployment manifests |