【发布时间】:2020-03-08 17:57:12
【问题描述】:
我有 2 个使用 docker-compose up 启动的容器。 第一个我只是从 docker hub nginx:stable 我在集线器的 php 之上构建的第二个
dockerfile
FROM composer:1.9.3
RUN mkdir /fatfree
RUN ["composer","require","bcosca/fatfree-core","--working-dir","/fatfree"]
FROM php:7.4-fpm
COPY --from=0 /fatfree /fatfree
我也在上述文件中尝试了VOLUME /fatfree,但无济于事。
docker-compose.yml
version: "3.7"
services:
webserver:
image: nginx:stable
ports:
- "80:8080"
volumes:
- ./www:/www
- fatfree:/fatfree
links:
- php
php:
build:
context: .
dockerfile: dockerfile
volumes:
- ./www:/www
- "fatfree:/fatfree"
volumes:
fatfree:
如果我正确解释了 docker 文档,我的 www/index.php 应该能够看到 /fatfree 中的任何内容,但它没有。文件夹本身显示出来,但它看起来是空的。
如果我以交互方式运行 dockerfile docker container run -i -t test bash ,则 /fatfree 文件夹存在并且它包含我希望它拥有的所有文件。
有很多 stackoverflow 问题询问如何实现这一点,它们似乎都表明我正在做的实际上是好的,但它不起作用,我不知道为什么。 任何建议表示赞赏。
【问题讨论】:
标签: docker docker-compose dockerfile docker-volume