**以新磁盘路径/chroot为例**

***注意！！！！***

**如果需要修改mysql的磁盘路径记得一定要备份数据库的数据 以 digital_operation和platomix_xxl_job为例**

```shell
# docker exec -i mysql sh -c 'mysqldump -uroot -pPlatomix@mysql123 digital_operation' >    digital_operation_v1.0.sql
# docker exec -i mysql sh -c 'mysqldump -uroot -pPlatomix@mysql123 platomix_xxl_job' > platomix_xxl_job.sql
```

1. 在/chroot路径下创建/chroot/webapp/uploads，/chroot/docker

   `#  mkdir /chroot/webapp/uploads`

   `# mkdir /chroot/webapp/logs`

   `# mkdir /chroot/docker`

2. 将原uploads路径下的图片复制到新创建的uploads路径下

   `# cp -r /**/**/uploads /chroot/weapp/uploads`

   将原/data/webapp/www下的www文件夹复制到新创建的webapp路径下

   `# cp -r /data/webapp/www /chroot/webapp`

   将原/data/modul/mysql,/data/modul/reids,/data/modul/nginx复制到新创建的docker目录下

   ```shell
   # cp -r /data/modul/mysql /chroot/docker/
   # cp -r /data/modul/redis /chroot/docker/
   # cp -r /data/modul/nginx /chroot/docker/
   ```



3. 修改docker-compose.yml文件,以修改bi为例

   ```yml
   #BI模块      
      gmetry-bi:
         image: docker.platomix.net:10000/platomix/platomix-gmetry-bi:${bi_version}
         container_name: bi
         environment:
            JAVA_OPTS: "-Xms2g -Xmx2g -XX:MetaspaceSize=128M -XX:MaxMetaspaceSize=256M -XX:MaxDirectMemorySize=256m -XX:+UseConcMarkSweepGC -XX:+DisableExplicitGC -XX:+CMSParallelRemarkEnabled -XX:CMSInitiatingOccupancyFraction=75 -XX:HeapDumpPath=/dockerDir/logs/bi/jvm.hprof -Xloggc:/dockerDir/logs/bi/gc.log"
            SPRINGBOOT_PARAMS: "--server.port=6060 --spring.profiles.active=docker --blade.domain=http://114.116.34.93"
         volumes:
            - /data/webapp:/dockerDir
         #ports:
         #   - "6060:6060"
         networks:
            - net_webapp
            
   ## 修改其中的volumes这一项
   ## 将原来的路径映射做修改
   ## /data/webapp:/dockerDir >> /chroot/webapp:/dockerDir
   ```

4. **注意比较特殊的是项目升级模块**

   ```yml
   #项目升级模块
      gmetry-upgrade:
         image: docker.platomix.net:10000/platomix/platomix-gmetry-upgrade:${upgrade_version}
         container_name: upgrade
         user: root
         environment:
            JAVA_OPTS: "-Xms1g -Xmx1g -XX:MetaspaceSize=128M -XX:MaxMetaspaceSize=256M -XX:HeapDumpPath=/dockerDir/logs/upgrade/jvm.hprof -Xloggc:/dockerDir/logs/upgrade/gc.log"
            SPRINGBOOT_PARAMS: "--server.port=6868 --spring.profiles.active=test"
         volumes:
            - /data/webapp:/dockerDir
            - /data/docker:/dockerData
            - /usr/bin/docker:/usr/bin/docker
            - /var/run/docker.sock:/var/run/docker.sock
            - /usr/bin/docker-compose:/usr/bin/docker-compose
            - /usr/local/bin/docker-compose:/usr/local/bin/docker-compose
         # ports:
         #   - "6868:6868"
         networks:
            - net_webapp
            
   ## 修改其中的volumes这一项
   ## 将原来的路径映射做修改
   ## /data/webapp:/dockerDir >> /chroot/webapp:/dockerDir
   ```

5. 修改docker-compose.ym中nginx的配置

   ```yml
      #nginx
      nginx:
         image: nginx:1.23
         container_name: nginx
         restart: always
         privileged: true
         ports: 
            - "80:80"
            - "443:443"
         volumes:
            - /data/module/nginx/logs:/var/log/nginx
            - ./nginx/html:/usr/share/nginx/html
            - ./nginx/proxy_params:/etc/nginx/proxy_params
            - ./nginx/nginx.conf:/etc/nginx/nginx.conf
            - ./nginx/conf.d:/etc/nginx/conf.d
            - ./nginx/cert:/etc/nginx/cert
            - /data/webapp:/dockerDir
         networks:
            - net_webapp
     
   ## 修改其中的volumes这一项
   ## 将原来的路径映射做修改
   ## /data/module/nginx/logs:/var/log/nginx >> /chroot/docker/nginx/logs:/var/log/nginx
   ## /data/webapp:/dockerDir >> /chroot/webapp:/dockerDir
   ```

6. 修改docker-compose.ym中mysql的配置

   ***注意 ！！！！***

   **修改路径之前一定要备份数据避免数据丢失**

   ```yml
      #mysql
      mysql:
         image: mysql:8
         container_name: mysql
         restart: always
         #ports: 
         #   - "3306:3306" #暴露给宿主机使用的端口，服务连接mysql使用mysql:3306
         volumes:
            - /data/module/mysql/logs:/var/log/mysql
            - /data/module/mysql/data:/var/lib/mysql
            - ./mysql/my.cnf:/etc/mysql/my.cnf  #自定义my.cnf，主要修改字符集编码为utf8mb4
            - ./mysql/sqls:/docker-entrypoint-initdb.d    #初始化sql文件放这个目录下，自动执行
         environment:
            TZ: Asia/Shanghai
            MYSQL_ROOT_PASSWORD: Platomix@mysql123
         networks:
            - net_webapp
           
   ## 修改其中的volumes这一项
   ## 将原来的路径映射做修改
   ## /data/module/mysql/logs:/var/log/mysql >> /chroot/docker/docker/mysql/logs:/var/log/mysql
   
   ## /data/module/mysql/data:/var/lib/mysql >> /chroot/docker/docker/mysql/logs:/var/log/nginx
   ```



7. 修改docker-compose.ym中redis的配置

   ```yml
      #redis
      redis:
          image: redis:5.0
          container_name: redis
          restart: always
          #ports:
          #   - "6379:6379"
          command: redis-server /usr/local/etc/redis/redis.conf  #使用配置文件方式
          volumes:
             - /data/module/redis:/data
             - /data/module/redis/logs:/logs
             - ./redis/redis.conf:/usr/local/etc/redis/redis.conf
          networks:
            - net_webapp
            
   ## 修改其中的volumes这一项
   ## 将原来的路径映射做修改
   ## /data/module/redis:/data >> /chroot/docker/docker/redis/logs:/data
   ## /data/module/redis/logs:/logs >> /chroot/docker/docker/redis/logs:/logs
   ```

8. 重新启动项目 - 进入docker-compose.yml文件所在目录

   ```shell
   docker-compose up -d mysql redis
   docker-compose up -d gmetry-xxljob gmetry-bi gmetry-system gmetry-lowcode gmetry-pdf gmery-upgrade
   ```

9. 最后启动nginx

   ```shell
   docker-compose up -d nginx
   ```

   

