Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build Nexus Private Server through Docker in Linux Server by ​

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article is to share with you about how to build a Nexus private server through Docker on the Linux server. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

How to build Nexus private server on Linux server through Docker

First, install Nexus

1. Create a location to store data

# enter a directory, and you can create a folder called cd / srv# with mkdir nexus-data# permission, otherwise the startup will report an error and have no permission to operate chmod 777 nexus-data.

2. Start

Execute the following command, and the image will be pulled and started automatically.

Docker run-d-p 8081 srv/nexus-data:/nexus-data 8081-- name nexus- v / restart=always sonatype/nexus3

Check the startup log through docker logs-f nexus. When a Started Sonatype Nexus OSS appears, it can be accessed via http://ip:8081.

Click Sign in in the upper right corner to log in. The account number is admin. The password needs to be checked in the image.

# enter the image docker exec-it nexus bash# to check the password. The path will be prompted in the login box, and then you can copy it. After a successful login, you will be allowed to change your password cat / nexus-data/admin-password

After entering the home page, click Browse on the left menu bar to view the warehouse you own.

II. Nexus warehouse

1. Warehouse type

Nexus has four types of warehouses and four types of warehouses

A, warehouse

The warehouse name describes the maven-centralmaven central repository. By default, the jarmaven-releases private repository, release version, jarmaven-snapshots private library snapshot (debug version) jarmaven-public repository is pulled from https://repo1.maven.org/maven2/, and the above three repositories are grouped together to provide services, which can be used in the local maven basic configuration settings.xml.

B, type

Type description group (warehouse group type) is used to facilitate developers to set their own repository hosted (host type) internal project release repository (internal developers Publish warehouse for storage) proxy (agent type) search for data from the remote central warehouse (you can click on the Configuration page of the corresponding warehouse to sign the value of the Remote Storage Location attribute, that is, the path of the remote warehouse being proxied) virtual (virtual type) virtual warehouse (this is basically useless, focus on the use of the above three warehouses)

2. Process of pulling jar package

Maven can download components directly from the host repository or from the proxy warehouse, while the proxy warehouse downloads and caches the components indirectly from the remote warehouse. For convenience, Maven can download components from the warehouse group, while the warehouse group has no actual content (shown in the following figure with dotted lines, it will turn to the included host warehouse or proxy warehouse to obtain the contents of the actual components)

3. Create a warehouse

After the above explanation, we already have an understanding of the warehouse. Next, we create a warehouse, which is divided into agent warehouse (proxy), host warehouse (hosted) and warehouse group (group). Click the small screw above the home page and then select Repositories to enter the warehouse management list, and then we can start to create our warehouse. Be sure to select maven2 when choosing the warehouse type.

A, proxy agent warehouse

We use Ali's central warehouse.

B, hosted host warehouse

Releases and snapshot types of repositories can be created here, and here is a demonstration of one

C, group warehouse group

III. Project configuration

After the first two chapters, we have deployed nexus on the Linux server and created our repository, and then we will try to configure it in the project.

1. Create a Maven project

To demonstrate, just create a tool class to play with. Here is the directory structure.

2. Pom file

Here, I have equipped the release warehouse for demonstration. In fact, I should configure the snapshot warehouse at the same time. Maven will determine whether there is a-SNAPSHOT after the version, and if so, publish it to the snapshots warehouse, otherwise publish it to the release warehouse.

4.0.0 com.gjing demo 1.0 demo Demo project for Spring Boot 1.8 UTF-8 releases http:// IP:8081/repository/me-release/ org.apache.maven.plugins maven-compiler-plugin 3.8.1 1.8 1.8 org.apache.maven.plugins maven-deploy-plugin 2.8.2 in your nexus warehouse

3. Maven configuration setting file

The id must be consistent with that in the project pom file

Releases admin admin123

IV. Release

If you are using the IDEA development tool, you can click deploy directly in the right toolbar Maven tool, or you can directly enter the root directory of the project on the command line to mvn deploy.

At this time, our jar package will also appear on the nexus private server.

At this point, the release was successful.

5. Use

There are two ways for a maven project to use nexus as a remote repository, the first is to make changes in the project's pom.xml so that a single project uses the nexus repository, and the other is to make changes by modifying maven's configuration file settings.xml so that all projects use the nexus repository. We take the second one here, all we need is setting.xml. In addition, pull the address of jar's private server warehouse and just write our warehouse group to ok, because when this group was created, it already included the other three repositories.

1. Settings.xml file

Find mirrors in the settings file of maven, and add the mirror,url of our group warehouse to fill in the address of the group we created. Id and name can be filled in freely, and mirrorOf can be the same as mine.

Mynexus myself nexus repository http://xxx:8081/repository/me-group/ central

2. Verification

You only need to introduce the pom file in other projects, which can be successfully introduced and the tool classes we just defined can be used normally in the project.

Thank you for reading! This is the end of the article on "how to build Nexus private server through Docker on the Linux server". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report