docker安装nexus3

简介: docker安装nexus3以及搭建本地私服

1 安装nexus3

查看镜像文件

docker search nexus3

拉取镜像

docker pull sonatype/nexus3

启动容器

docker run -d --restart=always --name=nexus3 -p8081:8081 --privileged=true -e INSTALL4J_ADD_VM_PARAMS="-Xms512M -Xmx512M -XX:MaxDirectMemorySize=512M" -v /mydata/nexus:/var/nexus-data sonatype/nexus3

打开neuxs3

image.png

点击右上角的登录,默认用户名是admin。查看密码,需要登录进入容器里执行如下命令

# 进入容器
docker exec -it nexus3 bash
# 查看密码
cat /nexus-data/admin.password  

下图红色部分就是密码,注意,查询结果最后的bash-4.4$不是密码部分
image.png

输入密码后回车
image.png

提示修改密码
image.png

image.png

2 批量上传本地仓库到私服

在本地仓库目录新建一个mavenimport.sh文件,内容如下

#!/bin/bash
# copy and run this script to the root of the repository directory containing files
# this script attempts to exclude uploading itself explicitly so the script name is important
# Get command line params
while getopts ":r:u:p:" opt; do
    case $opt in
        r) REPO_URL="$OPTARG"
        ;;
        u) USERNAME="$OPTARG"
        ;;
        p) PASSWORD="$OPTARG"
        ;;
    esac
done
 
find . -type f -not -path './mavenimport\.sh*' -not -path '*/\.*' -not -path '*/\^archetype\-catalog\.xml*' -not -path '*/\^maven\-metadata\-local*\.xml' -not -path '*/\^maven\-metadata\-deployment*\.xml' | sed "s|^\./||" | xargs -I '{}' curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} ;

本地需要安装git,鼠标右键点击Open Git Bash here,然后在打开的窗口执行以下命令即可开始上传

# admin是私服用户名   admin123是私服密码
./mavenimport.sh -u admin -p admin123 -r http://192.168.119.128:8081/repository/maven-releases/

image.png

命令执行期间,可以看到私服里已经有上传上去的依赖了
image.png

查找需要的依赖,如fastjson
image.png

找到自己需要的版本,点击进去
image.png

就可以看到依赖了
image.png

3 上传单个仓库到私服

执行以下命令,将fastjson1.1.37发布到私服里

mvn deploy:deploy-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37 -Dpackaging=jar -Dfile=fastjson-1.1.37.jar -Durl=http://localhost:8079/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty

4 setting.xml配置连接私服

setting.xml配置好后,以后就可以直接从私服下载jar包了,setting.xml完整文件如下

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
 
  <localRepository>D:\work\repositorys</localRepository>
 
  <pluginGroups>
  </pluginGroups>
  <proxies>
  </proxies>
  <servers>
    <server>
        <id>maven-public</id>
        <username>admin</username>
        <password>admin123</password>
    </server>
    <server>
        <id>maven-releases</id>
        <username>admin</username>
        <password>admin123</password>
    </server>
  </servers>

  <mirrors>
     <mirror>
      <id>maven-public</id>
      <name>maven-public</name>
      <url>http://192.168.188.101:8081/repository/maven-public/</url>
      <mirrorOf>*</mirrorOf>
     </mirror>
  </mirrors>

  <profiles>
    <profile>
        <id>jdk-1.8</id>
        <activation>
        <activeByDefault>true</activeByDefault>
        <jdk>1.8</jdk>
        </activation>
        <properties>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
            <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
        </properties>
    </profile>
    
    <profile>
        <id>nexus</id>
        <repositories>
            <repository>
                <id>maven-public</id>
                <url>http://192.168.188.101:8081/repository/maven-public/</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>true</enabled></snapshots>    
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>maven-public</id>
                <url>http://192.168.188.101:8081/repository/maven-public/</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>true</enabled></snapshots>
             </pluginRepository>
        </pluginRepositories>
    </profile>
  </profiles>
    <activeProfiles>
        <activeProfile>nexus</activeProfile>
    </activeProfiles>
</settings>

其中注意如下细节:

image.png

image.png

相关文章
|
8天前
|
Docker 容器
Docker安装及镜像源修改
本文介绍了Docker的安装过程和如何修改Docker镜像源以加速下载。包括更新系统包、安装所需软件包、设置yum源、安装Docker以及验证安装是否成功。接着,提供了修改Docker镜像源的步骤,包括创建配置文件、编辑配置文件以设置镜像加速地址,并提供了几个常用的国内镜像源地址。最后,通过重启Docker服务和检查配置是否生效来完成镜像源的修改。
Docker安装及镜像源修改
|
9天前
|
Docker 容器
centos7.3之安装docker
centos7.3之安装docker
|
1月前
|
NoSQL 关系型数据库 Redis
mall在linux环境下的部署(基于Docker容器),Docker安装mysql、redis、nginx、rabbitmq、elasticsearch、logstash、kibana、mongo
mall在linux环境下的部署(基于Docker容器),docker安装mysql、redis、nginx、rabbitmq、elasticsearch、logstash、kibana、mongodb、minio详细教程,拉取镜像、运行容器
mall在linux环境下的部署(基于Docker容器),Docker安装mysql、redis、nginx、rabbitmq、elasticsearch、logstash、kibana、mongo
|
1月前
|
Ubuntu Linux Docker
Ubuntu 18.04 安装Docker实战案例
关于如何在Ubuntu 18.04系统上安装Docker的实战案例,包括安装步骤、配置镜像加速以及下载和运行Docker镜像的过程。
163 3
Ubuntu 18.04 安装Docker实战案例
|
1月前
|
存储 Linux Docker
CentOS 7.6安装Docker实战案例及存储引擎和服务进程简介
关于如何在CentOS 7.6上安装Docker、介绍Docker存储引擎以及服务进程关系的实战案例。
93 3
CentOS 7.6安装Docker实战案例及存储引擎和服务进程简介
|
19天前
|
Prometheus 监控 Cloud Native
docker安装prometheus+Granfan并监控容器
【9月更文挑战第14天】本文介绍了在Docker中安装Prometheus与Grafana并监控容器的步骤,包括创建配置文件、运行Prometheus与Grafana容器,以及在Grafana中配置数据源和创建监控仪表盘,展示了如何通过Prometheus抓取数据并利用Grafana展示容器的CPU使用率等关键指标。
|
2月前
|
消息中间件 Docker 容器
消息中间件RabbitMQ---Docker安装RabbitMQ、以及RabbitMQ的基本使用【二】
这篇文章提供了RabbitMQ的安装和基本使用教程,包括如何使用Docker拉取RabbitMQ镜像、创建容器、通过浏览器访问管理界面,以及如何创建交换机、队列、绑定和使用direct、fanout和topic三种类型的交换器进行消息发布和接收的测试。
消息中间件RabbitMQ---Docker安装RabbitMQ、以及RabbitMQ的基本使用【二】
|
2月前
|
关系型数据库 MySQL Java
腾讯云服务器的使用、服务器中使用Docker安装常见的软件、如何将一个项目发布到服务器
这篇文章介绍了在腾讯云服务器上使用Docker安装常见软件的过程,包括安装MySQL、Redis和Tomcat,并提供了解决连接问题的方法。同时,还涉及了服务器中安装JDK 1.8的步骤和如何将项目打包部署到服务器上的指导,包括注意事项和操作提示。
腾讯云服务器的使用、服务器中使用Docker安装常见的软件、如何将一个项目发布到服务器
|
2月前
|
Ubuntu Docker 索引
2024年最新版 Ubuntu 20+ 上安装 Docker
这篇文章提供了在Ubuntu 20+版本上安装Docker的详细步骤,包括更新软件包索引、安装依赖包、添加Docker官方GPG密钥、设置Docker稳定版仓库、安装Docker CE以及验证安装是否成功,并指导如何将用户添加到docker组以非root用户身份运行Docker。
|
2月前
|
存储 搜索推荐 应用服务中间件
深入探索Docker 安装 Tomcat
【8月更文挑战第26天】
44 4
下一篇
无影云桌面