Docker images for Sonatype Nexus Repository Manager 2 with the Oracle JDK.
For Nexus Repository Manager 3, please refer to https://github.com/sonatype/docker-nexus3
# docker build --rm --tag sonatype/nexus oss/ # docker build --rm --tag sonatype/nexus:pro pro/
To run (if port 8081 is open on your host):
# docker run -d -p 8081:8081 --name nexus sonatype/nexus:oss
To determine the port that the container is listening on:
# docker ps -l
$ curl http://localhost:8081/nexus/service/local/status
To build, copy the Dockerfile and do the build:
$ docker build --rm=true --tag=sonatype/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
/opt/sonatype/nexus/conf/nexus.propertiesis the properties file.
here are overridden in the JVM invocation.
A persistent directory,
/sonatype-work, is used for configuration,
logs, and storage. This directory needs to be writeable by the Nexus
process, which runs as UID 200.
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. Defaults to '/nexus'
MAX_HEAP, passed as -Xmx. Defaults to
MIN_HEAP, passed as -Xms. Defaults to
JAVA_OPTS. Additional options can be passed to the JVM via this variable.
-server -XX:MaxPermSize=192m -Djava.net.preferIPv4Stack=true.
LAUNCHER_CONF. A list of configuration files supplied to the
Nexus bootstrap launcher. Default:
These can be user supplied at runtime to control the JVM:
$ docker run -d -p 8081:8081 --name nexus -e MAX_HEAP=768m sonatype/nexus
There are two general approaches to handling persistent
storage requirements with Docker. See Managing Data in
Use a data volume container. Since data volumes are persistent
until no containers use them, a container can be created specifically for
this purpose. This is the recommended approach.
$ docker run -d --name nexus-data sonatype/nexus echo "data-only container for Nexus" $ docker run -d -p 8081:8081 --name nexus --volumes-from nexus-data sonatype/nexus
Mount a host directory as the volume. This is not portable, as it
relies on the directory existing with correct permissions on the host.
However it can be useful in certain situations where this volume needs
to be assigned to certain underlying storage.
$ mkdir /some/dir/nexus-data && chown -R 200 /some/dir/nexus-data $ docker run -d -p 8081:8081 --name nexus -v /some/dir/nexus-data:/sonatype-work sonatype/nexus
Adding Nexus Plugins
Creating a docker image based on
sonatype/nexus is the suggested
process: plugins should be expanded to
See https://github.com/sonatype/docker-nexus/issues/9 for an example
concerning the Nexus P2 plugins.
Looking to contribute to our Docker image but need some help? There's a few ways to get information or our attention:
I am trying to add repository through dockerfile using this image.Can someone help me out...
If you're on K8S, you can get around the directory permissions issue by setting a security context on your pod, e.g.:
securityContext: fsGroup: 5678 supplementalGroups: 
When will 3.0.0 be available?
I use a grsec enabled kernel and cannot run this image due to some flags that need to be enabled. See . Any chance we can get the java binary in the container to get these flags set?
I have found today that when I pulled latest, it wouldn't run under the nexus user. There was an issue with shared libs not being accessible. I couldn't even run an ls, whoami, or bash. I was able to get everything to work by adding in --user root. Not a great solution, but I haven't had time to research any further.
I had the same issue "java.lang.IllegalStateException: Nexus work directory already in use: /sonatype-work at com.google.common.base.Preconditions.checkState(Preconditions.java:200)"
Looks like a permission issue in folder "/some/dir/nexus-data". I tried with a simple chmod and it got fixed.
I have same problem that previous comment.
I can do that:
$ docker run -d --name nexus-data sonatype/nexus echo "data-only container for Nexus"
$ docker run -d -p 8081:8081 --name nexus --volumes-from nexus-data sonatype/nexus
But i want to do:
$ mkdir /some/dir/nexus-data && chown -R 200 /some/dir/nexus-data
$ docker run -d -p 8081:8081 --name nexus -v /some/dir/nexus-data:/sonatype-work sonatype/nexus
And is not working
at org.sonatype.nexus.bootstrap.jetty.JettyServer$JettyMainThread.run(JettyServer.java:247) ~[nexus-bootstrap-2.11.3-01.jar:2.11.3-01]
Exception in thread "main" java.lang.IllegalStateException: Nexus work directory already in use: /sonatype-work
Hi. Thanks for the image. I can't map the /sonatype-work volume to a directory on the host, though. I get this error: java.lang.IllegalStateException: Nexus work directory already in use: /sonatype-work.
Is there a workaround for that?
Thanks for the image. I'd have a request for improvement though:
Currently, you have the context path hard coded in the docker default CMD. We need a different context path in our setup. Could you consider one of the following adaptations:
- Introduce an ENV variable for the context path, like MIN_HEAP or MAX_HEAP
- Move JAVA_OPTS after the manual -D settings so we can use it to overwrite these settings