【发布时间】:2015-08-18 21:30:21
【问题描述】:
我有 docker-compose.yml,里面只有 nginx,但是在运行它时,在 nginx 容器中找不到卷。 Dockerfile 在另一个设置中工作正常,并且 src 目录存在,所以我不明白为什么这在这里不起作用?
Nginx 说:
nginx_1 | 2015/06/04 09:33:32 [错误] 13#0: *1 open() “/var/www/web/index.html”失败(2:没有这样的文件或目录), 客户端:172.17.42.1,服务器:,请求:“GET /index.html HTTP/1.1”, 主机:“本地主机:8085”
树:
.
├── code
├── docker-compose.yml
├── logs
├── nginx
└── readme.md
docker-compose.yml
nginx:
build: nginx/
volumes:
- code/dist:/var/www
ports:
- 8085:80
Dockerfile:
FROM ubuntu:14.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y \
nginx
RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf
ADD vhost.conf /etc/nginx/sites-enabled/default
ADD start.sh /start.sh
EXPOSE 80
ENTRYPOINT ["/start.sh"]
更新
当我在 docker-compose.yml 中将 nginx 重命名为 othernginx 时,它可以工作??
这是为什么呢?
似乎它会干扰来自另一个构建的其他容器,docker-compose 是否不会在不同的 docker-compose.yml 之间分离容器?
【问题讨论】:
-
可以添加“ls -l code/dist”的结果吗?
-
还有,为什么不用Nginx官方镜像呢?
-
code/dist 基本上就是 index.html。我尝试使用官方图像,但切换回在这里工作的容器,以避免配置错误
-
我至少现在让它工作了,但出现了另一个问题,请参阅更新
-
@ivoba -- 关于不同 docker-compose 设置之间的干扰,docker-compose 有缓存,所以这可能会导致您看到的内容,但我只是猜测我的有限码头工人知识。使用
docker-compose build --no-cache构建时可以禁用缓存,因此您可以测试它是否有帮助。
标签: nginx docker docker-compose