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:

  1. Install Docker.
  2. Install Docker on the host machine by following the specific steps outlined in the official Docker documentation.
  3. Create a Nexus container.
  4. Create a Nexus container in Docker by running the following command: docker run -d -p 8081:8081 –name nexus sonatype/nexus3
  5. Wait for the Nexus to start.
  6. 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.
  7. Set up a Maven repository server.
  8. Open the Nexus console in your browser and log in with the default username and password (admin/admin123).
  9. Click on “Repositories” in the left side panel, then click on “Create repository”.
  10. Choose Maven 2 (hosted) as the repository type, then click Next.
  11. Enter a repository name in the Name field, such as maven-releases, and then click Create repository.
  12. Set up Maven.
  13. 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.

  14. Deploy to Maven repository
  15. 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.

  16. Run Maven build
  17. 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.

广告
Closing in 10 seconds
bannerAds