简体   繁体   中英

Docker: How to change mountpoint of volumes?

I have a web application running in container. The application allows users to upload files. These files are stored in Docker volumes web_data1 and web_data2 .

Due to changes in the application, I need to change the mountpoint of these volumes ie the data that were in /srv/app/web_data1_mountpoint , now need to be moved to /srv/app/web_data1_changed_mountpoint .

What is the proper way to do this?

docker-compose.yml

version: "3"

volumes:
  web_data1:
  web_data2:

services:
  web:
    build:
      context: .
      dockerfile: .docker/Dockerfile
    image: web-image
    ports:
      - 80:80
      - 443:443
    volumes:
      - web_data1:/srv/app/web_data1_mountpoint
      - web_data2:/srv/app/web_data2_mountpoint

That depends a bit of the image you are using. Just changing the volume would work in your docker-compose.yml like this:

volumes:
      - web_data1:/srv/app/web_data1_changed_mountpoint
      - web_data2:/srv/app/web_data2_changed_mountpoint

But I dont know, what your image does with the directory. Maybe something inside the image depends on the directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM