See https://github.com/clearent/nexus for source
A Dockerfile for Sonatype Nexus Repository Manager 3, based on Alpine.
To run, binding the exposed port 8081 to the host.
$ docker run -d -p 8081:8081 --name nexus clearent/nexus
Default credentials are:
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
Installation of Nexus is to
A persistent directory,
/nexus-data, is used for configuration,
logs, and storage.
Two environment variables can be used to control the JVM arguments
JAVA_MAX_MEM, passed as -Xmx. Defaults to
JAVA_MIN_MEM, passed as -Xms. Defaults to
These can be used supplied at runtime to control the JVM:
$ docker run -d -p 8081:8081 --name nexus -e JAVA_MAX_MEM=2048M clearent/nexus
If you want to run Nexus in SSL, you need to create a Java keystore file with your certificate. See the Jetty documentation for help.
You will need to mount your keystore to the appropriate directory and pass in the keystore password as well.
$ docker run -d -p 8443:8443 --name nexus -v /path/to/your-keystore.jks:/nexus-data/keystore.jks -e JKS_PASSWORD="changeit" clearent/nexus
Nexus will now serve its' UI on HTTPS on port 8443 and redirect HTTP requests to HTTPS.
There are two general approaches to handling persistent storage requirements
with Docker. See Managing Data in Containers
for additional information.
Use a data volume container. Since data volumes are persistent
until no containers use them, a container can created specifically for
this purpose. This is the recommended approach.
$ docker run -d --name nexus-data clearent/nexus echo "data-only container for Nexus" $ docker run -d -p 8081:8081 --name nexus --volumes-from nexus-data clearent/nexus
Mount a host directory as the volume.
$ docker run -d -p 8081:8081 --name nexus -v /some/dir/nexus-data:/nexus-data clearent/nexus
@ronsenlinux I have never attempted an HA setup before, but I imagine if you have the /nexus-data directory on something like an NFS share that all your instances of Nexus mount, it may work. However, I would be cautious of this, since Nexus keeps stateful info like pid and lock files in that directory, and with >1 instance of Nexus reading/writing to the same directory there could be issues. If that works, then you will need to load balance between your instances with something like HAProxy.
Sonatype has a brief article about HA with Nexus2 (http://www.sonatype.org/nexus/2015/07/10/high-availability-ha-and-continuous-integration-ci-with-nexus-oss/) that may be of some help.
@HERE How to scale this nexus? I want a HA setup.
@ sameetn Do you mind creating an issue here?: https://github.com/clearent/nexus
To help you troubleshoot, I'll need some more info, like what host OS you are on and what docker run command you used to start the container.
At first glance, something looks way off, because /nexus-data should have several directories inside of it and it should be owned by the nexus user.
I get a permissions denied in creating a file after mounting a volume. I tried running the container after creating the external mount folder owned by root on the host system.
/opt/sonatype/nexus # cd /nexus-data/
/nexus-data # ls -al
drwx------ 2 root root 6 Jan 11 16:44 .
drwxr-xr-x 20 root root 4096 Jan 11 16:57 ..
/nexus-data # touch file
touch: file: Permission denied
@ianedwardthomas, is this affecting the startup of the container?
There is a known issue about these warnings (https://issues.sonatype.org/browse/NEXUS-10049) but they should be harmless. Unfortunately, I have no control over this, since it's baked into Sonatype's code.
Tried latest image and also did own build of image. Maybe getting permission issue mentioned earlier. Maybe the su-exec is not working as expected?
- exec su-exec nexus bin/nexus run
2016-12-15 06:28:54,116+0000 WARN [pool-15-thread-1] SYSTEM org.apache.karaf.features.internal.service.FeaturesServiceImpl - Can't update cfg file
java.io.FileNotFoundException: /opt/sonatype/nexus/etc/karaf/org.apache.karaf.command.acl.feature.cfg (Permission denied)
2016-12-15 06:28:54,138+0000 WARN [pool-15-thread-1] SYSTEM org.apache.karaf.features.internal.service.FeaturesServiceImpl - Can't update cfg file
java.io.FileNotFoundException: /opt/sonatype/nexus/etc/karaf/org.apache.karaf.command.acl.system.cfg (Permission denied)
no problem :)
I have just updated the "latest" tagged image to use Nexus 3.1.0, so if you want the newest, you can re-pull or use the corresponding tag
Thank you so much! Sonaypes official image doesn't work, but this one does!
how did you fix the privilege thingies or is it possible that you link the source repo?