1. 获取镜像

  1. # 查看可用的稳定版本
  2. sudo docker search nexus
  3. sudo docker pull sonatype/nexus3
  4. sudo docker image ls |grep nexus

2. 创建数据卷

  1. sudo mkdir -p /home/nexus-data
  2. # 赋予data目录读写权限
  3. sudo chmod 777 /home/nexus-data

3. 启动容器

  1. sudo docker run -d -p 8081:8081 --name nexus \
  2. --restart=always \
  3. -v /home/nexus-data:/var/nexus-data \
  4. -e TZ=Asia/Shanghai \
  5. sonatype/nexus3
  6. sudo docker start nexus
  7. sudo docker restart nexus
  8. sudo docker stop nexus
  9. sudo docker rm nexus

4. 配置

org.apache.maven.plugins maven-deploy-plugin 2.7 org.apache.maven.plugins maven-source-plugin 2.2.1 package jar

  1. - **Maven配置(setting.xml)**
  2. ```xml
  3. <servers>
  4. <server>
  5. <id>polarisrs</id>
  6. <username>admin</username>
  7. <password>admin123</password>
  8. </server>
  9. </servers>

5. 验证

sudo docker logs nexus
sudo docker exec -it nexus /bin/bash

# 查看密码(默认账户口令:admin/admin123)
# 在nexus3中,其密码已经由默认改成随机生成
cat /nexus-data/admin.password

# 打包发布命令
mvn deploy

WebUI:http://${domain}:8081