docker搭建maven私服--nexus
1、准备
一台可以上网的服务器(或者虚拟机、个人电脑等)并安装有docker
2、查找镜像
docker search nexus
3、选取第一个镜像拉取
docker pull sonatype/nexus3
4、查看拉取的镜像
docker images
5、启动nexus镜像
docker run -p 5000:5000 -p 8081:8081 --name nexus \
--restart=always \
-v /opt/nexus-data:/nexus-data \
-d --hostname nexus sonatype/nexus3
默认密码: admin/admin123
参数解释:
5000
:是用于镜像仓库的服务端口8081
:是nexus的访问端口-v
:将nexus镜像的数据挂载到主机的目录下
6、查看容器日志
docker logs nexus
7、Nexus 3.x 镜像权限问题
问题:
[root@localhost opt]# docker logs nexus
mkdir: cannot create directory '../sonatype-work/nexus3/log': Permission denied
mkdir: cannot create directory '../sonatype-work/nexus3/tmp': Permission denied
Java HotSpot(TM) 64-Bit Server VM warning: Cannot open file ../sonatype-work/nexus3/log/jvm.log due to No such file or directory
Warning: Cannot open log file: ../sonatype-work/nexus3/log/jvm.log
Warning: Forcing option -XX:LogFile=/tmp/jvm.log
Unable to update instance pid: Unable to create directory /nexus-data/instances
/nexus-data/log/karaf.log (No such file or directory)
Unable to update instance pid: Unable to create directory /nexus-data/instances
解决方法:
#将目录权限归属设定为 200
chown -R 200 /opt/nexus-data/
最新的Nexus 3.x还支持Docker仓库