【发布时间】:2019-02-16 19:51:07
【问题描述】:
我尝试运行 nginx,如下所示:
docker-compose.yml
version: '3'
services:
web:
image: nginx
ports:
- "3011:80"
运行docker-compose up后,发现nginx在127.0.0.1:3011运行成功
但如果我在 dockerHub 复制 nginx's dockerfile:
并更改 docker-compose.yml 如下:
version: '3'
services:
web:
build:
context: .
dockerfile: Dockerfile
ports:
- "3011:80"
那么 nginx 将无法在 127.0.0.1:3011 工作。
这是为什么呢?
【问题讨论】:
-
使用上面链接的 dockerfile 和它的 compose 对此进行了测试,这对我来说效果很好。也许您需要运行
docker-compose build,然后运行docker-compose up --force-recreate,这可能是您使用的陈旧容器可能已损坏。 -
哇,谢谢伙计!有用!非常感谢!
-
太棒了!将此移至答案部分;)
标签: docker docker-compose dockerfile