[英]Docker mounting file into container clears directory
I have a container that already contains files in a structure like this:我有一个容器,它已经包含这样的结构中的文件:
/var/www/html/pages/index.php
/var/www/html/pages/page1.php
/var/www/html/pages/page2.php
...
Now I have a page5.php which I want to mount into that container.现在我有一个 page5.php,我想将它安装到该容器中。
So my idea was:所以我的想法是:
server:
image: myapp
volumes:
- ./pages/page5.php:/var/www/html/pages/page5.php
- ./pages/page6.php:/var/www/html/pages/page6.php
Which mounted the file in place.将文件安装到位。 Problem now is that all other files in this directory are gone and only page5.php and page6.php are placed in.
现在的问题是这个目录中的所有其他文件都没有了,只有 page5.php 和 page6.php 被放入。
I there a way to mount that external files and keep the existing files in this directory?我有办法挂载该外部文件并将现有文件保留在此目录中吗?
Its the typical behavior when you mount volumes.这是您挂载卷时的典型行为。
The best would be bring all pages to ./pages/
and the mount to the container最好将所有页面都带到
./pages/
并将装载到容器
|_pages/
|_ page1.php
|_ page2.php
|_ ...
|_ page5.php
|_ page6.php
In docker-compose
file在
docker-compose
文件中
server:
image: myapp
volumes:
- ./pages/:/var/www/html/pages/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.