Public | Automated Build

Last pushed: 3 months ago
Short Description
Sonatype Nexus
Full Description


Docker images for Sonatype Nexus Repository Manager 2 with the Oracle JDK.
For Nexus Repository Manager 3, please refer to

To build:

# 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

To test:

$ 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: admin / admin123

  • 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. Notably:
    /opt/sonatype/nexus/conf/ is the properties file.
    Parameters (nexus-work and nexus-webapp-context-path) defined
    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 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
    • LAUNCHER_CONF. A list of configuration files supplied to the
      Nexus bootstrap launcher. Default: ./conf/jetty.xml ./conf/jetty-requestlog.xml

    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

Persistent Data

There are two general approaches to handling persistent
storage requirements with Docker. See Managing Data in
additional information.

  1. 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
  2. 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 /opt/sonatype/nexus/nexus/WEB-INF/plugin-repository.
See for an example
concerning the Nexus P2 plugins.

Getting Help

Looking to contribute to our Docker image but need some help? There's a few ways to get information or our attention:

Docker Pull Command
Source Repository

Comments (15)
5 months ago

I am trying to add repository through dockerfile using this image.Can someone help me out...

a year ago

If you're on K8S, you can get around the directory permissions issue by setting a security context on your pod, e.g.:

        fsGroup: 5678
        supplementalGroups: [5678]

More info:

a year ago

Nexus 3 is now available from a different repo -

a year ago

When will 3.0.0 be available?

a year ago

I use a grsec enabled kernel and cannot run this image due to some flags that need to be enabled. See [1]. Any chance we can get the java binary in the container to get these flags set?


2 years ago

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.

2 years ago

I had the same issue "java.lang.IllegalStateException: Nexus work directory already in use: /sonatype-work at"

Looks like a permission issue in folder "/some/dir/nexus-data". I tried with a simple chmod and it got fixed.

2 years ago

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$ ~[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

any idea?

2 years ago

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?

2 years ago

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