1、拉取镜像
docker pull sonatype/nexus3
[root@localhost ~]# docker pull sonatype/nexus3
Using default tag: latest
latest: Pulling from sonatype/nexus3
0bb54aa5e977: Pull complete
941e1e2b31a8: Pull complete
fb7cd7cf24c9: Pull complete
4e63afcbf773: Pull complete
Digest: sha256:81d182285d279081e80e74dbd13cb544fdf4255efadd61321436a577f56b87ad
Status: Downloaded newer image for sonatype/nexus3:latest
docker.io/sonatype/nexus3:latest
2、配置外部挂载文件夹
mkdir -p /usr/local/nexus-data && chmod 751 /usr/local/nexus-data
[root@localhost local]# mkdir -p /usr/local/nexus-data && chmod -R 771 nexus-data/
[root@localhost local]# ll
总用量 50504
drwxr-xr-x. 9 root root 220 2月 29 12:57 apache-tomcat-8.5.35
drwxr-xr-x. 3 root root 60 9月 12 2019 java
drwxr-x---. 13 root root 4096 3月 16 17:53 jenkins
drwxr-xr-x. 5 root root 133 3月 24 10:02 jenkins-publish
drwxr-xr-x. 4 root root 89 3月 4 02:19 maven
drwxr-x--x. 2 root root 6 4月 10 17:33 nexus-data
3、安装
docker run -d -p 28080:8081 --name nexus -v /usr/local/nexus-data:/nexus-data sonatype/nexus3
[root@localhost ~]# docker run -d -p 28080:8081 --name nexus -v /usr/local/nexus-data:/nexus-data sonatype/nexus3
e8751fb2c8f4fae2a33b0a0b466aa8f4bdab200bde095a7ac0edea52e9105c8c
[root@localhost ~]# docker container ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e8751fb2c8f4 sonatype/nexus3 "sh -c ${SONATYPE_DI…" 3 seconds ago Up 2 seconds 0.0.0.0:28080->8081/tcp nexus
717172393d6f portainer/portainer "/portainer" 6 months ago Up 9 hours 0.0.0.0:9000->9000/tcp upbeat_poincare
4、进入挂载目录,找到登录密码
[root@localhost nexus-data]# ll
总用量 28
-rw-r--r--. 1 200 200 36 4月 10 18:11 admin.password
drwxr-xr-x. 3 200 200 21 4月 10 18:11 blobs
drwxr-xr-x. 312 200 200 8192 4月 10 18:10 cache
drwxr-xr-x. 6 200 200 113 4月 10 18:11 db
drwxr-xr-x. 3 200 200 19 4月 10 18:11 elasticsearch
drwxr-xr-x. 3 200 200 45 4月 10 18:10 etc
drwxr-xr-x. 2 200 200 6 4月 10 18:10 generated-bundles
drwxr-xr-x. 2 200 200 33 4月 10 18:10 instances
drwxr-xr-x. 3 200 200 19 4月 10 18:10 javaprefs
-rw-r--r--. 1 200 200 1 4月 10 18:10 karaf.pid
drwxr-xr-x. 3 200 200 18 4月 10 18:11 keystores
-rw-r--r--. 1 200 200 14 4月 10 18:10 lock
drwxr-xr-x. 3 200 200 112 4月 10 18:11 log
drwxr-xr-x. 2 200 200 6 4月 10 18:11 orient
-rw-r--r--. 1 200 200 5 4月 10 18:10 port
drwxr-xr-x. 2 200 200 6 4月 10 18:11 restore-from-backup
drwxr-xr-x. 8 200 200 262 4月 10 18:11 tmp