Create a Docker registry user in Nexus
Overview¶
First time setup note: When Nexus is first deployed, the Nexus admin gives you the initial credentials for the
adminanddocker-deployeraccounts. Change them immediately after first login.
By default Nexus only has an admin account. Using admin for Docker push/pull is a security risk because:
- No audit trail per user — all actions show as
admin - If credentials leak, attacker has full Nexus admin access
- Cannot restrict what the user can do
This guide sets up a dedicated docker-deployer user with only the permissions needed to push, pull, browse, and delete Docker images.
User Strategy¶
| User | Purpose | Can Push | Can Pull | Can Browse | Can Delete | Can Admin |
|---|---|---|---|---|---|---|
admin |
Nexus administration only | |||||
docker-deployer |
CI/CD pipelines, developers | |||||
docker-reader (optional) |
Read-only consumers |
Step 1 — Create Role¶
Go to:
Fill in:
| Field | Value |
|---|---|
| Role ID | docker-deployer |
| Role Name | Docker Deployer |
| Role Description | Push, pull, browse and delete Docker images |
Applied Privileges¶
Click Modify Applied Privileges and add:
nx-repository-view-docker-*-browse
nx-repository-view-docker-docker-hosted-browse
nx-repository-view-docker-docker-hosted-read
nx-repository-view-docker-docker-hosted-add
nx-repository-view-docker-docker-hosted-edit
nx-repository-view-docker-docker-hosted-delete
nx-search-read
Click Save.
Do NOT add
nx-repository-admin-docker-docker-hosted-browse— that is an admin-level privilege that gives access to repository configuration settings, not content browsing.
Step 2 — Create User¶
Go to:
Fill in:
| Field | Value |
|---|---|
| ID | docker-deployer |
| First Name | Docker |
| Last Name | Deployer |
deployer@yourcompany.com |
|
| Password | <PASSWORD> |
| Status | Active |
| Roles | docker-deployer |
Click Save.
Note: Use the same value for ID and username for clarity. Pick a strong password and keep it in the team password manager, not in this page. Change the initial password after first login via top-right menu → Change password.
Step 3 — Test Access¶
Test Docker login and push¶
# Login with new user
docker login registry.nexus.castis.io
# Username: docker-deployer
# Password: <PASSWORD> (change after first login)
# Push a test image
docker pull alpine:latest
docker tag alpine:latest registry.nexus.castis.io/alpine:latest
docker push registry.nexus.castis.io/alpine:latest
# Pull the image back
docker pull registry.nexus.castis.io/alpine:latest
Test UI access¶
Login to https://nexus.castis.io with docker-deployer credentials.
You should be able to:
- See Browse tab in left sidebar
- Click Browse → docker-hosted
- See image tree (v2/blobs, image names)
- Search for components
You should NOT be able to: - Access Settings () administration - See other repository types configuration
Step 4 — Update Kubernetes imagePullSecret¶
Update your Kubernetes secret to use the new user instead of admin:
# Delete old secret
kubectl delete secret nexus-registry -n default 2>/dev/null
# Create with docker-deployer user
kubectl create secret docker-registry nexus-registry \
--docker-server=registry.nexus.castis.io \
--docker-username=docker-deployer \
--docker-password=<password> \
--namespace=default
Or create per-namespace:
for ns in default dev staging production; do
kubectl create secret docker-registry nexus-registry \
--docker-server=registry.nexus.castis.io \
--docker-username=docker-deployer \
--docker-password=<password> \
--namespace=$ns
done
Reference in your Deployment:
spec:
imagePullSecrets:
- name: nexus-registry
containers:
- name: myapp
image: registry.nexus.castis.io/myimage:latest
Privilege Reference¶
What each privilege does¶
| Privilege | What it allows |
|---|---|
nx-repository-view-docker-*-browse |
Browse all docker repositories in the UI |
nx-repository-view-docker-docker-hosted-browse |
Enter and browse docker-hosted repository contents |
nx-repository-view-docker-docker-hosted-read |
Pull images, view manifests and layers |
nx-repository-view-docker-docker-hosted-add |
Push new images and tags |
nx-repository-view-docker-docker-hosted-edit |
Overwrite existing tags |
nx-repository-view-docker-docker-hosted-delete |
Delete images and tags |
nx-search-read |
Use the Search tab in UI |
nx-repository-admin-docker-docker-hosted-browse |
Admin only — view repository configuration settings |
Read-only user (optional)¶
If you need a separate read-only user for consumers (e.g. production deployments that should never push):