Skip to content

Nexus3 Configuration

TheSpiritMan edited this page Dec 26, 2022 · 5 revisions

Nexus3 Configuration

  • Nexus3 is a private Repository Manager.
  • Different artifact including docker images can be hosted in the Nexus Repository.

Nexus3 Requirement

  • Nexus will running in docker container, so docker must be installed in your system.
  • By default, nexus runs in port 8081, so port 8081 must be free to use for use in your system. IF not, we can forward the port different free port.

Nexus3 Container

  • The command to run the nexus3 container:

    docker run -d -p 8081:8081 -p 8082:8082 -v nexus-data:/nexus-data --name nexus --memory="3g" --cpus="1" sonatype/nexus3
    
  • Output:

  • We created a new docker volume named as nexus-data to save all the data for future use.

  • We have forwarded Port 8081 and Port 8082 into host machine. Port 8081 is for Nexus Webpage and Port 8082 is for Docker Private Registry which we will use later on the project.

Nexus Webpage

  • Visit http://<your_ip>:8081 to access the nexus. Do not use localhost, problem may arise.

  • Since my private ip address is 192.168.18.8. So I can visit http://192.168.18.8:8081.

  • The default webpage is somehow same as below:

  • Click in the Sign In button. We can see that it promts a form for credential. We can that, username is admin and the password can be found in /nexus-data/admin.password.

  • Command to get password:

    docker exec -it nexus cat /nexus-data/admin.password
    
  • Output:

  • Remember, the $ sign from the output is from my shell. So the password is only 5306178f-e5cc-48d3-9117-bb463e27de14.

  • Login into the nexus webpage using the credential.

  • Once logged in, you will be asked to setup wizard for the Nexus Repository. It includes the new password and control access form. For my case, I have set new pasword as a admin and disable anonymous access.

  • Once everything is configured, we can see Welcome page:

Artifact Repository

  • Let's create a artifact repository.

  • Click on the Setting button. We can see multiple option:

  • Select Repositories from them. We can see that there are already some repository created. If we want, we can use maven-releases and maven-snapshots repository from them but we will practice creating our own repository. It will be best if we delete default repository in Enterprise Level and create custom Repository.

  • We will create 2 repositories to store artifacts. One for Release version and another for Snapshot version.

Release Repository

  • To create new Release repository, click on Create Repository button. We can lots of option. From there, select maven2 hosted. Fill the form as follows and select Release from Drop-Down-Menu of Version Policy. Click on Create Repository button to create a repository.

  • We can see, our newly created repository in Repositories list.

  • Click on that repository and we gets all the details about the Repository including the URL to upload the artifacts from third-party app like Jenkins.

Snapshot Repository

  • To create new Snapshot repository, click on Create Repository button. We can lots of option. From there, select maven2 hosted. Fill the form as follows and select Snapshot from Drop-Down-Menu of Version Policy. Click on Create Repository button to create a repository.

  • We can see, our newly created repository in Repositories list.

  • Click on that repository and we gets all the details about the Repository including the URL to upload the artifacts from third-party app like Jenkins.

Now Nexus Repository is ready to accept artifact from Third-Party Tools like Jenkins using admin credentials. So goto Jenkins Configuration Page in Manage Nexus section and continue with the project.

Docker Private Registry

  • Click on the Setting button. We can see multiple option:

  • Select Repositories from them. We can see that there are already some repository created.

  • To create new Docker repository, click on Create Repository button. We can lots of option. From there, select docker hosted.

  • Fill the form as follows and tick mark on Enable Docker V1 API. Click on Create Repository button to create a repository.

  • We can see our docker-private-repo in list of Repositories:

  • Click on that to get more info:

Now Nexus Repository is ready to accept docker images using admin credentials. So goto Jenkins Configuration Page in Docker Image Build section and continue with the project.

Clone this wiki locally