- 查看当前容器挂载的目录
            
            
              bash
              
              
            
          
          [root@test-server01 ~]# docker inspect -f "{{.Mounts}}" jenkins
[{bind  /etc/localtime /etc/localtime   true rprivate} {bind  /opt/jenkins_data /var/jenkins_home   true rprivate}]- 复制数据目录到数据盘
            
            
              bash
              
              
            
          
          [root@test-server01 opt]# cp -r jenkins_data /home/
[root@test-server01 opt]# cd /home/
[root@test-server01 home]# ll
total 211472
-rw-r--r--  1 root    root    216535040 Mar  2  2024 centos.tar.gz
drwx------  3 git     git           129 Oct 30 05:10 git
drwx------  2 jenkins jenkins        62 Oct 22 10:53 jenkins
drwxr-xr-x 22 root    root         8192 Oct 30 16:15 jenkins_data
[root@test-server01 home]# chown -R jenkins.jenkins jenkins_data
#跨机器需要提前创建好Jenkins用户
[root@test-server01 home]# ll
total 211472
-rw-r--r--  1 root    root    216535040 Mar  2  2024 centos.tar.gz
drwx------  3 git     git           129 Oct 30 05:10 git
drwx------  2 jenkins jenkins        62 Oct 22 10:53 jenkins
drwxr-xr-x 22 jenkins jenkins      8192 Oct 30 16:15 jenkins_data- 停掉当前Jenkins
            
            
              bash
              
              
            
          
          [root@test-server01 home]# docker stop jenkins
jenkins- 启动新容器
            
            
              bash
              
              
            
          
          [root@test-server01 etc]# docker run -d --name jenkins_qy -p 8888:8080 -p 7777:50000  --privileged=true -v /home/jenkins_data:/var/jenkins_home -v /etc/localtime:/etc/localtime -v /etc/timezone:/etc/timezone jenkins/jenkins:latest
a248447cb4f874bbdcb02f2b34704bde5b696c5e782629b317f98328522ffc15- 访问新的Jenkins网址

至此迁移成功了、原有数据还在。