Skip to content

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

  1. Go to Administration → Repositories → Create Repository
  2. Select docker (proxy)
  3. 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
  1. Click Save

Step 2 — Remove Port from docker-hosted

Since docker-group will own port 8082, remove it from docker-hosted:

  1. Go to Repositories → docker-hosted → Edit
  2. Set HTTP → uncheck / blank
  3. Click Save

Step 3 — Create Docker Group Repository

  1. Go to Administration → Repositories → Create Repository
  2. Select docker (group)
  3. Configure:
Field Value
Name docker-group
Online checked
HTTP 8082
HTTPS blank
Allow anonymous docker pull checked
  1. Member repositories (order matters!):
Members:
  1. docker-hosted     ← first (private images, higher priority)
  2. proxy-dockerhub   ← second (public images fallback)
  1. Click Save

Step 4 — Configure k3s to Use Nexus as Mirror

On each k3s node:

sudo nano /etc/rancher/k3s/registries.yaml
mirrors:
  docker.io:
    endpoint:
      - "https://registry.nexus.castis.io"

configs:
  "registry.nexus.castis.io":
    auth:
      username: <NEXUS_USER>
      password: <NEXUS_PASSWORD>
sudo systemctl restart k3s

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)

docker push registry.nexus.castis.io/playtelly/myapp:latest

Pull private image

docker pull registry.nexus.castis.io/playtelly/myapp:latest

Pull public image (auto cached)

docker pull registry.nexus.castis.io/nginx:latest

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:

docker buildx imagetools inspect registry.nexus.castis.io/playtelly/<image>:prod-latest

Expected output:

Manifests:
  Platform: linux/amd64  
  Platform: linux/arm64  


Troubleshooting

Platform warning on Apple Silicon

WARNING: The requested image's platform (linux/amd64) does not match detected host platform (linux/arm64/v8)
Fix: Ensure image is built with --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