Dokcer搭建maven私有服务器-nexus3

2019-10-01  本文已影响0人  小迷糊紫靈

1、拉取镜像

docker pull sonatype/nexus3 

2、创建资源目录

mkdir nexus-data 

3、向资源目录授权

chown -R 200 nexus-data

4、创建容器

docker run -d --name nexus3 --restart=always -v /指定目录地址/nexus-data:/nexus-data sonatype/nexus3

执行完成命令之后 nexus3应该就能正常启动,但是无法通过外网访问。后期可以通过配置nginx或者apache等进行端口指向完成外网访问。同时也可以加上参数:-p 8081:8081 进行端口指向。

5、搭建完成的时候可能会出现无法启动的问题

docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:293: copying bootstrap data to pipe caused \"write init-p: broken pipe\"": unknown.

此时我们需要使用update还更新我们的系统,并且重启系统完成更新。
注意一点,如果我们没有进行授权会出现项目无限重启

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                                    PORTS               NAMES
bee1d877be16        sonatype/nexus3     "sh -c ${SONATYPE_DI…"   2 hours ago         Restarting (255) Less than a second ago                       nexus3

此时我们使用docker logs nexus3查看容器异常信息的时候会看到:

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
mkdir: cannot create directory '../sonatype-work/nexus3/log': Permission denied
mkdir: cannot create directory '../sonatype-work/nexus3/tmp': Permission denied
OpenJDK 64-Bit Server VM warning: Cannot open file ../sonatype-work/nexus3/log/jvm.log due to No such file or directory

的异常信息,此时关闭容器并对资源目录授权就可以解决。

上一篇 下一篇

猜你喜欢

热点阅读