Install Docker and set up Nexus 3 to build a Maven repository.
To install Nexus 3 on Docker and set up a Maven repository, you can follow these steps:
- Install Docker.
- Install Docker on the host machine by following the specific steps outlined in the official Docker documentation.
- Create a Nexus container.
- Create a Nexus container in Docker by running the following command: docker run -d -p 8081:8081 –name nexus sonatype/nexus3
- Wait for the Nexus to start.
- Wait for a while until Nexus is fully up and running. You can check if Nexus has started by accessing http://localhost:8081 in your browser.
- Set up a Maven repository server.
- Open the Nexus console in your browser and log in with the default username and password (admin/admin123).
- Click on “Repositories” in the left side panel, then click on “Create repository”.
- Choose Maven 2 (hosted) as the repository type, then click Next.
- Enter a repository name in the Name field, such as maven-releases, and then click Create repository.
- Set up Maven.
- Open the settings.xml file of Maven (usually located in the ~/.m2 directory) and add the following configuration:
my-nexus
admin admin123
This will allow Maven to authenticate with Nexus.
- Deploy to Maven repository
- Add the following configuration to the pom.xml file of the project:
my-nexus
My Nexus Repository
http://localhost:8081/repository/maven-releases/
This will allow you to deploy the built project to Nexus Maven repository.
- Run Maven build
- Run Maven build using the following command and deploy the build result to Nexus repository: mvn deploy
Now that you have successfully installed Nexus 3 using Docker and set up a Maven private repository, you can use the Nexus management interface to manage the repositories and publish build results.