cd /root
mkidr nexues
cd nexus
vi docker-compose.yml
version: '3.1'
services:
nexus:
restart: always
image: sonatype/nexus3
container_name: nexus
ports:
- 8081:8081
volumes:
- /usr/local/docker/nexus/data:/nexus-data
docker-compose up -d // 后台启动命令
docker logs -f nexus // 监听容器日志
chmod 777 /root/nexus/data
cd /root/neuxs/data
cat admin.password
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>你的密码</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>你的密码</password>
</server>
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>Nexus Release Repository</name>
<url>http://192.168.200.100:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://192.168.200.100:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
mvn deploy
mvn deploy:deploy-file ^
-DgroupId=坐标 ^
-DartifactId=坐标 ^
-Dversion=版本 ^
-Dpackaging=jar ^
-Dfile=jar本地的物理地址 ^
-Durl=http://192.168.200.100:8081/repository/maven-3rd/ ^
-DrepositoryId=nexus-releases ^
<repositories>
<repository>
<id>nexus</id>
<name>Nexus Repository</name>
<url>http://192.168.200.100:8081/repository/maven-public/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>Nexus Plugin Repository</name>
<url>http://192.168.200.100:8081/repository/maven-public/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
原文:https://www.cnblogs.com/lovling/p/12498612.html