$ run as a normal user# run as root (or with sudo)
Know it before you install
Three kinds of repositories. Proxy = a cache of a remote registry (Maven Central, npmjs, PyPI, Docker Hub). Hosted = your own packages (releases, snapshots, private images). Group = one URL that combines several repositories — clients use only the group.
| Item | Value |
|---|---|
| Edition | Nexus Repository Community Edition (free, with usage limits) or Pro |
| Image | sonatype/nexus3 |
| Data | /nexus-data (volume): database, blob stores, config, logs |
| First password | /nexus-data/admin.password |
| Port | 8081/tcp (UI and most formats); Docker repos need their own port or a path behind a proxy |
| Memory | settings in nexus.vmoptions or INSTALL4J_ADD_VM_PARAMS |
What you need: 4 CPU, 8 GB RAM, and a big disk for the blob store (packages grow fast).
Install with Docker (RHEL and Ubuntu)
docker volume create nexus-data
docker run -d --name nexus --restart unless-stopped -p 127.0.0.1:8081:8081 -p 127.0.0.1:8082:8082 -e INSTALL4J_ADD_VM_PARAMS="-Xms2g -Xmx2g -XX:MaxDirectMemorySize=2g" -v nexus-data:/nexus-data sonatype/nexus3:3.84.0
docker logs -f nexus
… Started Sonatype Nexus COMMUNITY
docker exec nexus cat /nexus-data/admin.password(Pin the version tag you test. Port 8082 is for a Docker hosted/group repository, below.) Without Docker, download the Linux bundle from Sonatype, unpack it to /opt/nexus, run it as a nexus user with a systemd unit — the steps after this are the same.
First configuration: the setup wizard
Open http://localhost:8081 (SSH tunnel) and sign in as admin with the password from admin.password. The wizard asks you to:
- Set a new admin password (the file is deleted afterwards).
- Disable anonymous access — unless you really want public read access.
Then in Settings → Repository → Repositories → Create repository:
| Repository | Type | Points to |
|---|---|---|
maven-central | maven2 (proxy) | https://repo1.maven.org/maven2/ (made by default) |
maven-releases, maven-snapshots | maven2 (hosted) | your builds (made by default) |
maven-public | maven2 (group) | the three above |
npm-proxy → npm-group | npm proxy + group | https://registry.npmjs.org |
pypi-proxy → pypi-group | pypi proxy + group | https://pypi.org |
docker-hub | docker (proxy) | https://registry-1.docker.io (with Docker Hub login to avoid limits) |
docker-private | docker (hosted) | your images |
docker-group | docker (group), HTTP connector 8082 | docker-private + docker-hub |
Also in Security: add the Docker Bearer Token Realm (for docker login) and npm Bearer Token Realm; create roles and users (or LDAP/SAML); give CI its own user with only deploy rights to the hosted repos.
Put Nexus behind Nginx with HTTPS — docker clients need HTTPS. Route nexus.example.com → 127.0.0.1:8081 and docker.example.com → 127.0.0.1:8082 (with client_max_body_size 0; for big image layers).
Connect the clients
<settings>
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>https://nexus.example.com/repository/maven-public/</url>
</mirror>
</mirrors>
<servers>
<server>
<id>nexus</id>
<username>ci-deploy</username>
<password>${env.NEXUS_PASSWORD}</password>
</server>
</servers>
</settings>npm config set registry https://nexus.example.com/repository/npm-group/
pip config set global.index-url https://nexus.example.com/repository/pypi-group/simple
docker login docker.example.com
docker pull docker.example.com/library/nginx:1.27
docker tag shop:1.4.0 docker.example.com/shop:1.4.0
docker push docker.example.com/shop:1.4.0Daily use: cleanup, tasks and the real uses
Packages pile up fast. In Settings → Repository → Cleanup Policies make rules (for example: snapshots older than 30 days, proxy components not downloaded for 90 days), attach them to repositories. In System → Tasks schedule:
- Admin – Cleanup repositories using their associated policies (daily),
- Admin – Compact blob store (weekly — deleted files really free the disk only after compaction),
- Docker – Delete unused manifests and images,
- Admin – Backup of the database (where your edition supports it) — plus a copy of the blob stores.
docker exec nexus du -sh /nexus-data/blobs
curl -s -u admin https://nexus.example.com/service/rest/v1/repositories | jq -r '.[].name'
curl -s -u admin https://nexus.example.com/service/rest/v1/status/check | jq .Real uses at work:
- Fast, reliable builds: CI downloads from Nexus on the local network, not from the internet.
- One place for the company's own artifacts (jars, npm packages, wheels, images, Helm charts).
- Control: block or audit packages; keep builds working when a public package is deleted.
Make it safe
Security checklist:
- Change the admin password; anonymous access off; personal users or SSO.
- HTTPS only (Nginx); port 8081/8082 only on localhost.
- Separate CI user with deploy rights only to hosted repos; user tokens instead of passwords.
- Credentials in CI secrets and
${env…}— never insettings.xmlin Git. - Cleanup policies + compaction so the disk never fills; monitor disk.
- Back up the database and blob stores; update Nexus (security fixes).
Update and remove
docker pull sonatype/nexus3:3.85.0
docker stop nexus && docker rm nexus
docker run -d --name nexus --restart unless-stopped -p 127.0.0.1:8081:8081 -p 127.0.0.1:8082:8082 -v nexus-data:/nexus-data sonatype/nexus3:3.85.0The data stays in the nexus-data volume. Read the upgrade notes — some versions migrate the database.
Fix common problems
| Problem | Cause | Fix |
|---|---|---|
admin.password file is missing | The password was already changed in the wizard. | Use the new password; otherwise follow Sonatype's admin reset steps. |
docker login fails: http: server gave HTTP response to HTTPS client | Docker needs HTTPS. | Put the Docker connector behind Nginx with TLS. |
docker login 401 | Docker Bearer Token Realm not active, or no rights. | Add the realm in Security → Realms; check the user role. |
| Disk full | No cleanup or no compaction. | Cleanup policies + the Compact blob store task. |
Nexus slow or OutOfMemoryError | Heap or direct memory too small. | Raise -Xmx and -XX:MaxDirectMemorySize (and the host RAM). |
| Maven still downloads from the internet | The mirror is not used. | <mirrorOf>*</mirrorOf> in settings.xml; mvn help:effective-settings. |
| Proxy repo returns 404 for a public package | Wrong remote URL or no outbound internet. | Check the remote URL; test from the Nexus host with curl. |
Next steps
- Quick how-tos: Run a package proxy.
- Command pages: mvn, npm, pip, docker.
- The clients: Python, Node.js, Docker. A registry only for images: Harbor.
- The proxy in front: Nginx.
1What is the difference between a proxy, a hosted and a group repository?
Proxy caches a public registry, hosted stores your own packages, group combines them behind one URL.
2You deleted many old components but the disk is still full. Why?
The space is freed only after the Compact blob store task runs.