Maven PW: Docker installation nexus3

Find nexus3 Mirror

docker search nexus

 

Mirrored pull nexus3

docker pull docker.io/sonatype/nexus3

View Mirror

docker images

Run nexus container

RUN = -id --privileged Docker to true --name = nexus3. . 4 --restart Always -p = 8081 : 8081 -v / topcheer / nexus3 / Nexus-Data: / Nexus-Data 8eb898be2a53 (id or name that is the container)
[root@topcheer ~]# docker ps -l
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
b4d0c5712512        8eb898be2a53        "sh -c ${SONATYPE_..."   8 hours ago         Up 3 hours          0.0.0.0:8081->8081/tcp   nexus3
[root@topcheer ~]#

Explained:
-id create guard vessel
--privileged = true to grant root privileges (to mount directory hierarchies must be true, otherwise the container shortage host access permissions)
--name name = Give your container a name
-p host port: container port mapping
-v host directory: directory directory is mounted container

 

 

Note:
After running the container configuration to access the host + port mapping when the host does not respond, wait a few minutes (depending on the configuration of varying duration), wait for initialization to complete a successful visit nexus3

Access nexus3

log in

The default admin password inside the container

[root@topcheer nexus-data]# docker exec -it b4d0c5712512 /bin/bash
bash-4.4$
bash-4.4$
bash-4.4$ cd /
bash-4.4$ ls -l
total 16
lrwxrwxrwx.   1 root  root     7 Aug 12  2018 bin -> usr/bin
dr-xr-xr-x.   2 root  root     6 Aug 12  2018 boot
drwxr-xr-x.  15 root  root  3100 Nov  6 08:16 dev
drwxr-xr-x.   1 root  root    66 Nov  6 08:03 etc
-rwxr-xr-x.   1 root  root  2120 Oct  9 16:17 help.1
drwxr-xr-x.   2 root  root     6 Aug 12  2018 home
lrwxrwxrwx.   1 root  root     7 Aug 12  2018 lib -> usr/lib
lrwxrwxrwx.   1 root  root     9 Aug 12  2018 lib64 -> usr/lib64
drwxr-xr-x.   2 root  root    21 Oct  9 16:17 licenses
drwx------.   2 root  root     6 Sep 16 12:24 lost+found
drwxr-xr-x.   2 root  root     6 Aug 12  2018 media
drwxr-xr-x.   2 root  root     6 Aug 12  2018 mnt
drwxr-xr-x.  16 nexus nexus 4096 Nov  6 08:16 nexus-data
drwxr-xr-x.   1 root  root    22 Oct  9 16:17 opt
dr-xr-xr-x. 334 root  root     0 Nov  6 08:16 proc
dr-xr-x---.   1 root  root    23 Sep 16 12:29 root
drwxr-xr-x.   1 root  root    18 Oct  9 16:16 run
lrwxrwxrwx.   1 root  root     8 Aug 12  2018 sbin -> usr/sbin
drwxr-xr-x.   2 root  root     6 Aug 12  2018 srv
dr-xr-xr-x.  13 root  root     0 Nov  6 08:09 sys
drwxrwxrwt.   1 root  root    30 Nov  6 08:04 tmp
-rwxr-xr-x.   1 root  root   341 Oct  9 16:17 uid_entrypoint.sh
-rwxr-xr-x.   1 root  root   267 Oct  9 16:17 uid_template.sh
drwxr-xr-x.   1 root  root    81 Sep 16 12:25 usr
drwxr-xr-x.   1 root  root    24 Nov  6 08:04 var
bash-4.4$ pwd
/
bash-4.4$ cd nexus-data/
bash-4.4$ ls -l
total 32
-rw-r--r--.   1 nexus nexus   36 Nov  6 08:05 admin.password
drwxr-xr-x.   3 nexus nexus   21 Nov  6 08:05 blobs
drwxr-xr-x. 296 nexus nexus 8192 Nov  6 08:16 cache
drwxr-xr-x.   6 nexus nexus  113 Nov  6 08:04 db
drwxr-xr-x.   3 nexus nexus   36 Nov  6 08:08 elasticsearch
drwxr-xr-x.   3 nexus nexus   45 Nov  6 08:04 etc
drwxr-xr-x.   2 nexus nexus    6 Nov  6 08:04 generated-bundles
drwxr-xr-x.   2 nexus nexus   33 Nov  6 08:04 instances
drwxr-xr-x.   3 nexus nexus   19 Nov  6 08:04 javaprefs
drwxr-xr-x.   2 nexus nexus    6 Nov  6 08:04 kar
-rw-r--r--.   1 nexus nexus    1 Nov  6 08:16 karaf.pid
drwxr-xr-x.   3 nexus nexus   18 Nov  6 08:04 keystores
-rw-r--r--.   1 nexus nexus   14 Nov  6 08:16 lock
drwxr-xr-x.   4 nexus nexus  125 Nov  6 08:17 log
drwxr-xr-x.   2 nexus nexus    6 Nov  6 08:04 orient
-rw-r--r--.   1 nexus nexus    5 Nov  6 08:16 port
drwxr-xr-x.   2 nexus nexus    6 Nov  6 08:04 restore-from-backup
drwxr-xr-x.   9 nexus nexus 4096 Nov  6 08:16 tmp
bash-4.4$ cat admin.password
8e7256d8-b6e4-4ea6-b5ca-2f0979493119bash-4.4$

登陆以后修改密码为admin1234

查看仓库

 

在项目中配置私服

拷贝public仓库地址

 

 

 

配置到你本地maven的settings文件
注意:是public group仓库地址而不是releases或snapshots仓库,public默认包含了这两个仓库

<profile>
        <id>dev</id>
        <repositories>
            <repository>
                <id>nexus</id>
                <url>http://nexus.topcheer.xyz:8081/nexus/content/groups/public/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>public</id>
                <name>Public Repositories</name>
                <url>http://nexus.topcheer.xyz:8081/nexus/content/groups/public/</url>
            </pluginRepository>
        </pluginRepositories>
    </profile>
 <activeProfiles> <activeProfile>dev</activeProfile> </activeProfiles>
 

配置maven settings文件的服务器用户名密码
注意:id为私服中releases和snapshots仓库名,必须一致

<server>
      <id>docker-hub</id>
      <username>admin</username>
      <password>Harbor12345</password>
    </server>
     <server>  
        <id>maven-releases</id>  
        <username>admin</username>  
        <password>admin123</password>  
      </server>  
      <server>  
        <id>maven-snapshots</id>  
        <username>admin</username>  
        <password>admin123</password>  
      </server> 

 

 

在项目父pom文件中配置部署环境,注意id及URL必须与nexus仓库对应

<distributionManagement>
        <repository>
            <id>maven-releases</id>
            <name>Nexus Release Repository</name>
            <url>http://192.168.180.112:8081/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>maven-snapshots</id>
            <name>Nexus Snapshot Repository</name>
            <url>http://192.168.180.112:8081/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

重新打开项目,对需要的模块进行deploy

 

 结果:

 

Guess you like

Origin www.cnblogs.com/dalianpai/p/11809668.html