简体   繁体   English

Docker:如何更改卷的挂载点?

[英]Docker: How to change mountpoint of volumes?

I have a web application running in container.我有一个在容器中运行的 Web 应用程序。 The application allows users to upload files.该应用程序允许用户上传文件。 These files are stored in Docker volumes web_data1 and web_data2 .这些文件存储在 Docker 卷web_data1web_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 .由于应用程序的变化,我需要更改这些卷的挂载点,/srv/app/web_data1_mountpoint ,现在需要移动到/srv/app/web_data1_changed_mountpoint

What is the proper way to do this?这样做的正确方法是什么?

docker-compose.yml 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:只需更改音量即可在您的 docker-compose.yml 中工作,如下所示:

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.也许图像中的某些内容取决于目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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