Nexus Repository Installation on Windows Server&Docker&Kubernetes

Çiğdem Kadakoğlu
5 min readMar 16, 2022

--

Nexus Repository-Windows Server-Docker-Kubernetes

Hi everyone, I will show you how to install Nexus Repository on Windows&Docker&Kubernetes in this article.

  • Firstly, we will click the Download button for Windows archive.
cigdemkadakoglu
  • To extract all the files from a zipped folder, right-click the zipped folder.
cigdemkadakoglu
  • Copy this directory to disk C. Open C:\Nexus\nexus-3.38.0–01-win64\nexus-3.38.0–01\bin and command prompt or powershell as administrator.
cigdemkadakoglu
  • To run Nexus Repository manually:
nexus.exe /run

It takes a little time.

cigdemkadakoglu

The default port is “8081” and You can browse Nexus at http://localhost:8081 or http://<SERVER_IP_ADDRESS>:8081 .

cigdemkadakoglu

The default username is “admin” . Password is located in the following directory. Copy and paste it on the panel.

  • Change the password after log in.
cigdemkadakoglu

Additionally, you can configure anonymous access is disabled or enabled.

cigdemkadakoglu

And Nexus Repository is ready!

To stop Nexus Repository, press Ctrl+C together in powershell or command prompt.

Running Nexus as a Service on Windows

nexus.exe script includes important commands for installing, starting, stopping, and uninstalling the service. Therefore we can run this script using command line.

Run the service:

nexus.exe /install Nexus-Repository-Service

Start the service:

nexus.exe /start Nexus-Repository-Service

Stop the service:

nexus.exe /stop Nexus-Repository-Service

Delete the service:

nexus.exe /uninstall Nexus-Repository-Service
cigdemkadakoglu

You can also changed Nexus-Repository-Service status with Services.

Services → Nexus-Repository-Service→ Properties.

cigdemkadakoglu

Installing with Docker

To install Nexus Repository with Docker is easy!

What we need to do now are specify port number and directory as the volume. I am using Docker Desktop on Windows now, hence i gave this directory and i changed the port number. You can give any directory or any port number you want. Open command prompt or powershell as administrator.

docker run -d -p 8082:8081 --name nexus-repo-service -v C:/Nexus/nexus-data:/nexus-data sonatype/nexus3:3.38.0docker ps

You can browse Nexus at http://localhost:8082 or http://<SERVER_IP_ADDRESS>:8082 .

The default username is “admin” . Password is located in the following directory. Copy and paste it on the panel.

cigdemkadakoglu
cigdemkadakoglu

And Nexus Repository is ready!

To stop Nexus Repository:

docker stop nexus-repo-service

To delete Nexus Repository:

docker rm nexus-repo-service

Installing with Docker-Compose

We can convert “docker run” command into a compose file as follows.

version: '3'
services:
nexus-repository-service:
container_name: nexus-repository
image: sonatype/nexus3:3.38.0
volumes:
- /C/Nexus/nexus-data:/nexus-data
ports:
- 8082:8081
networks:
- sonatype
networks:
sonatype:
driver: bridge

And then open command prompt or powershell as administrator.

Let’s run these commands in the docker-compose directory.

docker-compose up
docker-compose ps

You can browse Nexus at http://localhost:8082 or http://<SERVER_IP_ADDRESS>:8082 .

  • To stop Nexus Repository:
docker-compose down
cigdemkadakoglu

Installing with Kubernetes

We can convert Docker compose file into a Kubernetes file as follows.

We will create Kubernetes objects like namespace, deployment, and service.

apiVersion: v1
kind: Namespace
metadata:
name: devops-ns
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: "nexus-deployment"
namespace: devops-ns
labels:
app: "nexus"
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
selector:
matchLabels:
app: "nexus"
template:
metadata:
labels:
app: "nexus"
spec:
containers:
- image: sonatype/nexus3:3.38.0
env:
- name: MAX_HEAP
value: "1000m"
- name: MIN_HEAP
value: "400m"
imagePullPolicy: Always
name: "nexus"
ports:
- containerPort: 8081
name: "nexus"
volumeMounts:
- name: nexus-data
mountPath: /nexus-data
- name: tz-istanbul
mountPath: /etc/localtime
volumes:
- name: nexus-data
hostPath:
path: /nexus-data
- name: tz-istanbul
hostPath:
path: /usr/share/zoneinfo/Europe/Istanbul
restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
name: nexus-svc
namespace: devops-ns
spec:
type: NodePort
selector:
app: nexus
ports:
- name: "8081"
targetPort: 8081
port: 8081
nodePort: 32000

Let’s run these commands in the same directory.

kubectl create -f nexus-kubernetes.yaml
kubectl get po -n devops-ns

You can browse Nexus at http://<SERVER_IP_ADDRESS>:32000 .

Hope you find my article helpful. I wish everyone an awesome day!

You can check this article: File Upload&Download with a Nexus Repository Rest Api

--

--

Çiğdem Kadakoğlu

Docker Captain🐳🇹🇷👩‍✈️ | Microsoft MVP | Instructor | Senior Cloud&DevOps Engineer | CK{A|AD}-AZ{104|204|305|400|800|801|900}-DP900-AI{900|102}-PL900🐧🐳🌼☕