Migrate Sonatype Nexus Repository 3.38.0 to Docker Container

Migrate Sonatype Nexus Repository 3.38.0 to Docker Container
Photo by Pankaj Patel / Unsplash

Docker Setup

Transfer the Docker image to the private Docker registry

export SRC_DCKR_IMG=sonatype/nexus3 && \
export SRC_DCKR_TG=3.38.0 && \
docker pull $SRC_DCKR_IMG:$SRC_DCKR_TG && \
docker tag $SRC_DCKR_IMG:$SRC_DCKR_TG registry.bierochs.org/$SRC_DCKR_IMG:$SRC_DCKR_TG && \
docker tag registry.bierochs.org/$SRC_DCKR_IMG:$SRC_DCKR_TG registry.bierochs.org/${SRC_DCKR_IMG}:latest && \
docker push registry.bierochs.org/$SRC_DCKR_IMG:$SRC_DCKR_TG && \
docker push registry.bierochs.org/${SRC_DCKR_IMG}:latest
3.38.0: Pulling from sonatype/nexus3
8dfe9326f733: Pull complete
0d875a68bf99: Pull complete
c1a2af48c694: Pull complete
18238e9f24c5: Pull complete
a970fe737b83: Pull complete
Digest: sha256:0a3a9841690d732b497bfdae3f3dda28ecc60f3c0c9f83439e7d687a94294568
Status: Downloaded newer image for sonatype/nexus3:3.38.0
docker.io/sonatype/nexus3:3.38.0
The push refers to repository [registry.bierochs.org/sonatype/nexus3]
d17e45a4f748: Pushed
8d12fc82bf58: Pushed
5a745ebef99f: Pushed
c8013a2772b6: Pushed
7699752e6ed6: Pushed
3.38.0: digest: sha256:0a3a9841690d732b497bfdae3f3dda28ecc60f3c0c9f83439e7d687a94294568 size: 1371
The push refers to repository [registry.bierochs.org/sonatype/nexus3]
d17e45a4f748: Layer already exists
8d12fc82bf58: Layer already exists
5a745ebef99f: Layer already exists
c8013a2772b6: Layer already exists
7699752e6ed6: Layer already exists
latest: digest: sha256:0a3a9841690d732b497bfdae3f3dda28ecc60f3c0c9f83439e7d687a94294568 size: 1371

Change UID and GUI of the nexus user accordingly

usermod -u 200 nexus
groupmod -g 200 nexus
cd /opt/sonatype/
chown -R nexus. .*
chown -R nexus. *
cd /var/nexus_storage_default/
chown -R nexus. *
cd /var/nexus_storage
chown -R nexus. *

Create and run the Docker container

docker run -d \
  --name=bierochs-nexus3 \
  -e TZ=Europe/Vienna \
  -v /var/nexus_storage:/var/nexus_storage:z \
  -v /opt/sonatype/sonatype-work/nexus3:/nexus-data:z \
  -p 8082:8082 \ # configured in nexus.properties
  -p 5000:5000 \ # described at "Private Container Registry Setup" down below
  registry.bierochs.org/sonatype/nexus3:latest

Configuration

nexus.properties

cat /opt/sonatype/sonatype-work/nexus3/etc/nexus.properties
# Jetty section
application-port=8082
# application-host=0.0.0.0
# nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
# nexus-context-path=/

# Nexus section
# nexus-edition=nexus-pro-edition
# nexus-features=\
#  nexus-pro-feature

# nexus.hazelcast.discovery.isEnabled=true
#nexus.scripts.allowCreation=true

Private Container Registry Setup

Bildschirmfoto-2022-03-28-um-11.32.18

Reverse Proxy Setup

Artifact Repository Subdomain

Bildschirmfoto-2022-03-28-um-11.23.13

Bildschirmfoto-2022-03-28-um-11.24.42

Container Registry Subdomain

Bildschirmfoto-2022-03-28-um-11.27.30

Bildschirmfoto-2022-03-28-um-11.27.45

Me on Mastodon - This link is here for verification purposes.