docker-compose Nexus3配置私库

178 阅读1分钟

安装

1.下载 docker pull sonatype/nexus3
2.编辑docker-compose配置文件
sersion: '3'
services:
  nexus:
    image: sonatype/nexus3:latest  # 使用官方的 Nexus 3 镜像
    container_name: nexus
    user: "root:root"
    ports:
      - "18081:8081"  # 映射 Nexus Web UI 到主机的 8081 端口
    volumes:
      - ./nexus-data:/nexus-data  # 数据卷,用于持久化数据
    environment:
      - NEXUS_CONTEXT=/  # 可选,设置 Nexus 上下文路径
    networks:
      - my-network
    restart: unless-stopped  # 容器停止后自动重启,除非被手动停止

volumes:
  nexus-data:
    driver: local  # 使用本地驱动来持久化数据

networks:
  my-network:
    driver: bridge  # 使用默认的 bridge 网络驱动
3. 启动
docker-compose up -d
登录到nexus管理控制台

一: 创建porxy

1.点击create repository

image.png

2.输入代理地址
https://maven.aliyun.com/repository/public

image.png

如果还需要其他的仓库可以继续创建添加

二:应用

1. 选择pulbic组

image.png

2.移动到使用

image.png

3. 排序

image.png

4. 在maven的setting中配置地址

image.png