The 2020 State of the Software Supply Chain Report is available!

Study Shows High-Performance Dev Teams Fix OSS Vulns 26x Faster | Press Release

blog-logo Sonatype Blog

Sonatype Nexus Installation Using Docker

February 10, 2017 By Rajesh Kumar
1. Download the Docker image using following commands..
# docker pull sonatype/nexus

 

2. Build an image from a Nexus Dockerfile# docker build –rm –tag sonatype/nexus oss/

# docker build –rm –tag sonatype/nexus-pro pro/ (For Pro)

 

3. To run (if port 8081 is open on your host):
# docker run -d -p 8081:8081 –name nexus sonatype/nexus:oss
or to assign a random port that maps to port 8081 on the container:
# docker run -d -p 8081 –name nexus sonatype/nexus

 

4. To determine the port that the container is listening on:
# docker ps nexus

 

5. To test:
# curl http://localhost:8081/service/local/status

 

Notes:
1. Default credentials are: admin / admin123

 

2. It can take some time (2-3 minutes) for the service to launch in a new container. You can tail the log to determine once Nexus is ready:
# docker logs -f nexus

 

3. Installation of Nexus is to /opt/sonatype/nexus. Notably: /opt/sonatype/nexus/conf/nexus.properties is the properties file.Parameters (nexus-work and nexus-webapp-context-path) definied here are overridden in the JVM invocation.

 

4. A persistent directory, /sonatype-work, is used for configuration, logs, and storage. This directory needs to be writable by the Nexus process, which runs as UID 200.

 

5. Four environment variables can be used to control the JVM arguments
CONTEXT_PATH, passed as -Dnexus-webapp-context-path. This is used to define the
URL which Nexus is accessed.
MAX_HEAP, passed as -Xmx. Defaults to 768m.
MIN_HEAP, passed as -Xms. Defaults to 256m.
JAVA_OPTS. Additional options can be passed to the JVM via this variable.
Default: -server -XX:MaxPermSize=192m -Djava.net.preferIPv4Stack=true.
LAUNCHER_CONF. A list of configuration files supplied to the
Nexus bootstrap launcher. Default: ./conf/jetty.xml ./conf/jetty-requestlog.xml

 

6. These can be used supplied at runtime to control the JVM:

 

# docker run -d -p 8081:8081 –name nexus -e MAX_HEAP=768m sonatype/nexus

Reference: https://hub.docker.com/r/sonatype/nexus/

Tags: Docker

Written by Rajesh Kumar

Over 12 years of extensive experience in the Software Configurtion Management domain having depth knowledge of DevOps, Continous Integration and Delivery, Configuration Management, Build and Installer, Release Management and Application Management.