docker 19+
-- 拉取镜像
docker pull sonatype/nexus3:3.29.2
-- 挂载目录
mkdir -p /home/jamel/docker/software/nexus/data
# 主目录,升级迁移需要
mkdir -p /home/jamel/docker/software/nexus/sonatype-work
chmod 777 /home/jamel/docker/software/nexus/data/
docker run --privileged=true \
-e NEXUS_CONTEXT=nexus -d \
-p 8081:8081 \
--restart=always \
-m 4096m \
-e TZ=Asia/Shanghai \
--name=nexus \
-v /home/jamel/docker/software/nexus/data/:/nexus-data \
sonatype/nexus3:3.29.2
启动成功后获取初始登录密码
less /home/jamel/docker/software/nexus/data/admin.password
firewall-cmd --zone=public --add-port=8081/tcp --permanent
firewall-cmd --zone=public --add-port=8971/tcp --permanent
firewall-cmd --reload
旧服务器 192.168.100.6
新服务器 192.168.100.2
# 旧服务器数据备份
mkdir -p /home/jamel/docker/software/nexus/sonatype-work
# b9a3a4bb29f3 私服docker容器id
docker cp b9a3a4bb29f3:/opt/sonatype/sonatype-work/ /home/jamel/docker/software/nexus/
nexus主目录:conf/nexus.properties里面有sonatype-work的地址
docker exec -it nexus bash
#
/opt/sonatype/sonatype-work
# 新服务器执行-数据复制
scp -r [email protected]:/opt/docker/software/nexus/data /home/jamel/docker/software/nexus
chmod -R 777 /home/jamel/docker/software/nexus/data/
1.找到容器id
docker ps
2.编辑容器文件
vim /home/jamel/docker/data/lib/docker/containers/05d2b7232b106a7c133d81b4c3617e2042fffd0555be2efc661e52831da18044/config.v2.json
3.更换内存大小
我更换后的值为:INSTALL4J_ADD_VM_PARAMS=-Xms1536m -Xmx1536m -XX:MaxDirectMemorySize=1536m
4.重启nexus
docker restart nexus
解决私服空间被占满导致服务无法启动的问题