Nexus Repository Installation

Credentials

  • Nexus: after installation use admin/admin123

Sonatype Nexus on Docker

The procedure below describes the configuration of the Sonatype Nexus to run on the Docker host with IP address HOST_IP on unsecured port 8081 with the Docker repository configured on unsecured port 5000.

Info: https://hub.docker.com/r/sonatype/nexus3/

  1. For Ubuntu Linux system with Docker installed with APT package manager, add a new entry into /etc/docker/daemon.json to allow HTTP registries.

     {
     "insecure-registries" : ["HOST_IP:5000"]
     }
    

    Important! Restart docker daemon with the following command:

    $ sudo systemctl restart docker
    
  2. For Ubuntu Linux system with Docker installed with Snap package manager, add a new entry into /var/snap/docker/current/config/daemon.json for insecure-registries.

     {
     "insecure-registries" : ["HOST_IP:5000"]
     }
    

    Important! Restart docker daemon with the following command:

    $ sudo snap restart docker
    
  3. For CentOS 7.X/RedHat 7.X system, it will probably be necessary to change /etc/sysconfig/docker.

     # /etc/sysconfig/docker                                                                                                                                                                                                                                                      
     # Modify these options if you want to change the way the docker daemon runs                                                                                                                                                    
     OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false'
     if [ -z "${DOCKER_CERT_PATH}" ]; then
     DOCKER_CERT_PATH=/etc/docker
     fi
    
     INSECURE_REGISTRY="--insecure-registry=HOST_IP:5000"                                                                                                                                                                                                          
     ...
    

    Important! Restart docker daemon.

  4. Configure Persistent Storage and run Nexus Repository You have two options to use - either Docker volumes or host folders. Please make sure you have at least 40Gb free space for Docker volume.

    • Use a docker volume. Since docker volumes are persistent, a volume can be created specifically for this purpose. This is the recommended approach.

        $ docker volume create --name nexus-data
        $ docker run -d -p 8081:8081 -p 5000:5000 --restart=unless-stopped --name nexus -v nexus-data:/nexus-data sonatype/nexus3
      
    • Mount a host directory as the volume. This is not portable, as it relies on the directory existing with correct permissions on the host.

        $ mkdir -p /some/dir/nexus-data && chown -R 200 /some/dir/nexus-data
        $ docker run -d -p 8081:8081 -p 5000:5000 --restart=unless-stopped --name nexus -v /some/dir/nexus-data:/nexus-data sonatype/nexus3
      
  5. Go to Nexus UI on URL: http:///HOST_IP:8081/ and configure RAW and docker registry as described here.

Sonatype Nexus Repository on Linux Host OS

  1. Download latest version of Nexus3 from here.

  2. After the download is complete, if necessary, for further information about the installation and necessary setup, consult Installation and System Requirements.

  3. Install Java 1.8.0 and Sonatype Nexus on RedHat/CentOS.

     # sudo yum update -y
     # sudo yum install java-1.8.0-openjdk.x86_64
     # tar xzvf latest-unix.tar.gz
     # mv nexus /opt/
     # sudo echo 'run_as_user="nexus"' > /opt/nexus/bin/nexus.rc
     # sudo adduser nexus
     # sudo chown -R nexus:nexus /opt/nexus
    
  4. Install Java 1.8.0 and Sonatype Nexus on Ubuntu Linux.

     # sudo apt-get update -y
     # sudo apt-get install openjdk-8-jre
     # java -version
     openjdk version "1.8.0_171"
     OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11)
     OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)
    
     # tar xzvf latest-unix.tar.gz
     # mv nexus /opt/
     # sudo echo 'run_as_user="nexus"' > /opt/nexus/bin/nexus.rc
     # sudo adduser --no-create-home --disabled-login --disabled-password nexus
     # sudo chown -R nexus:nexus /opt/nexus
    
  5. Configure nexus /opt/nexus/bin.nexus.vmoptions.

     -Xms1200M
     -Xmx1200M
     -XX:MaxDirectMemorySize=2G
     -XX:+UnlockDiagnosticVMOptions
     -XX:+UnsyncloadClass
     -XX:+LogVMOutput
     -XX:LogFile=/opt/nexus-data/log/jvm.log
     -XX:-OmitStackTraceInFastThrow
     -Djava.net.preferIPv4Stack=true
     -Dkaraf.home=.
     -Dkaraf.base=.
     -Dkaraf.etc=etc/karaf
     -Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
     -Dkaraf.data=/opt/nexus-data
     -Djava.io.tmpdir=/opt/nexus-data/tmp
     -Dkaraf.startLocalConsole=false
    
  6. Download and extract to /opt/nexus-data latest nexus-data.

  7. Configure Nexus as service on RedHat/CentOS.

    Nexus start

     # sudo ln -s /opt/nexus/bin/nexus /etc/init.d/nexus
     # sudo chkconfig --add nexus
     # sudo chkconfig --levels 345 nexus on
     # sudo service nexus start
    
  8. Configure Nexus as service on Ubuntu Linux.

    /etc/systemd/system/nexus.service

    Nexus start

     # sudo systemctl daemon-reload
     # systemctl enable nexus.service
     # systemctl start nexus.service
    
  9. Go to Nexus UI on URL: http:///HOST_IP:8081/ and configure RAW and docker registry as described here.