[英]Volumes in docker-compose not working on Windows 7
Here's a sample docker-compose.yml
file. 这是一个示例
docker-compose.yml
文件。
version: '3'
services:
app:
build:
context: .
dockerfile: docker/Dockerfile
image: docker-test
container_name: docker-test
ports:
- 80:80
volumes:
- .:/srv/app
Here's the Dockerfile
这是
Dockerfile
FROM php:7.3-apache-stretch
COPY . /srv/app
COPY docker/vhost.conf /etc/apache2/sites-available/000-default.conf
RUN chown -R www-data:www-data /srv/app \
&& a2enmod rewrite
There are no errors in running this except file changes in .
除了中的文件更改外,运行此命令没有错误
.
are not reflected in realtime inside the container /src/app
. 不会实时反映在容器
/src/app
。 Any ideas what's wrong with it? 任何想法有什么问题吗?
For those who care, apparently the default setup in Docker Toolbox for Windows 7 doesn't read outside C:/Users
so you have to manually setup the shared folders in VirtualBox. 对于那些在乎的人来说,显然Windows 7的Docker Toolbox中的默认设置不会在
C:/Users
之外读取,因此您必须在VirtualBox中手动设置共享文件夹。 This article helped me. 这篇文章对我有所帮助。
Once you set that up, your docker-compose.yml
file needs to be like this: 设置好之后,您
docker-compose.yml
文件需要像这样:
volumes:
- <shared-folder>:/srv/app
Replace <shared-folder>
with the name of the shared folder in VirtualBox. 将
<shared-folder>
替换为VirtualBox中共享文件夹的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.