搭建Nexus(需要1.5G内存)
由于微服务的架构思想,一台服务器提供一种服务,所以在VMWare上新开一台虚拟机作为服务器,并安装操作系统(操作系统安装参考第一篇文章https://www.jianshu.com/p/bf03f8c30557,也可以使用VMWare的克隆)。
再次来到Docker Hub https://hub.docker.com ,找到Nexus的镜像 Nexus3 https://hub.docker.com/r/sonatype/nexus3 ,把镜像拖进Docler。
docker pull sonatype/nexus3
在 /usr/local/docker/nexus 目录下写一个 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
启动一下,然后出现了
Creating nexus ... done
Attaching to nexus
nexus | mkdir: cannot create directory '../sonatype-work/nexus3/log': Permission denied
nexus | mkdir: cannot create directory '../sonatype-work/nexus3/tmp': Permission denied
nexus | OpenJDK 64-Bit Server VM warning: Cannot open file ../sonatype-work/nexus3/log/jvm.log due to No such file or directory
nexus |
nexus | Warning: Cannot open log file: ../sonatype-work/nexus3/log/jvm.log
nexus | Warning: Forcing option -XX:LogFile=/tmp/jvm.log
nexus | Unable to update instance pid: Unable to create directory /nexus-data/instances
nexus | /nexus-data/log/karaf.log (No such file or directory)
nexus | Unable to update instance pid: Unable to create directory /nexus-data/instances
出现了 Permission denied 之类的权限问题,输入一条777命令chmod 777 /usr/local/docker/nexus/data
再docker-compose up
启动一下。后台就跑起来了,虽然还有各种警告
不用管他,在浏览器输入Docker宿主机的ip和Nexus的暴露端口 http://192.168.111.134:8081 发现Nexus已经可以打开了,登录账密默认为admin和admin123
现在,Nexus私服就算搭建完成了,如果需要继续操作控制台,可以 ctrl c 强退进程再 docker start id 重启容器。