是什么导致码头工人卷被填充? [英] what causes a docker volume to be populated?
问题描述
我正在运行以下命令:
docker run --name wiki --link wiki-mdb:mysql -p 9081:80 -v/var/data/wikimedia/apache2:/etc/apache2 -v/var/data/wikimedia/wiki:/var/www/html -d synctree/mediawiki
容器死了,因为apache2在/etc/apach2中找不到其配置文件...
and the container dies because apache2 cant find its config file in /etc/apach2 ...
好的,所以我再次运行命令,而没有使用apache2卷:
ok, so I run the command again without the apache2 volume as:
docker run --name wiki --link wiki-mdb:mysql -p 9081:80 -v/var/data/wikimedia/wiki:/var/www/html -d synctree/mediawiki
不仅有效,而且/var/data/wikimedia/wiki以空开始,并填充了所需的所有php文件.
and not only does it work ... but /var/data/wikimedia/wiki which started out as empty is populated with all the php files needed.
那有什么区别?为什么某些卷中填充了容器中的内容,而另一些卷则更喜欢将空白文件夹安装在容器内部配置之上?
so what is the difference? Why are some volumes populated with content from container while other volumes will prefer to mount the blank folder over top of a containers internal configuration?
我最终通过运行 sudo docker cp 9f9ba217a2ec:/etc/apache2 ./
来生成默认的apache2文件夹来解决我的问题...但是似乎应该有押韵或理由为什么在卷中生成内容?
I ended up solving my issue by running sudo docker cp 9f9ba217a2ec:/etc/apache2 ./
to generate a default apache2 folder ... however it seems like there should be some rhyme or reason to why content is generated in the volume or not.
我认为这可能与 Dockerfile 有关,但没有任何一条路径的具体引用.
I thought it might have something to do with the Dockerfile, but it does not have any specific reference to either path.
推荐答案
从 -v/var/data/wikimedia/apache2:/etc/apache2
开始,链接您的本地/var/容器中包含
.这将掩盖在生成时创建的容器文件夹.因为/etc/apache2
的data/wikimedia/apache2 /etc/apache2
是apache寻找配置的地方,所以将没有配置的/var/data/wikimedia/apache2
链接到/etc/apache2
导致服务器找不到配置并且无法启动.
Starting with -v /var/data/wikimedia/apache2:/etc/apache2
links your local /var/data/wikimedia/apache2
with /etc/apache2
within the container. This masks the container folder created at the build time. Because /etc/apache2
is where apache is looking for its configuration, linking /var/data/wikimedia/apache2
without configuration into /etc/apache2
results in server finding no configuration and failing to start.
将此卷保留为不会掩盖在构建时创建的容器中已经存在的/etc/apache2
文件夹,从而将配置文件保留在此处<在构建时完整执行code> Dockerfile 脚本.服务器找到合适的配置并按预期启动.
Leaving this volume out does not mask the already present /etc/apache2
folder within the container created at the build time, thus keeping configuration files placed by there the Dockerfile
script at the build time intact. The server finds a suitable configuration and starts as expected.
我不是php方面的专家,尤其是在什么时候生成的文件,但是我怀疑在服务器正常启动时,php文件已被填充到/var/www/html 代码>(显然)在容器中.因为后者只是到本地
/var/data/wikimedia/wiki
的链接,所以您还可以在主机系统上看到这些文件.
I am not a pro in php and in particular at which point which files are generated if at all, but I suspect that as the server starts normally php files are being populated into /var/www/html
in the container (apparently). Because the latter is just a link to your local /var/data/wikimedia/wiki
you can also see those files on your host system.
这篇关于是什么导致码头工人卷被填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!