【发布时间】:2018-03-13 11:18:49
【问题描述】:
这是我的基本 NGINX 设置!
web:
image: nginx
volumes:
- ./nginx:/etc/nginx/conf.d
....
我通过使用COPY ./nginx /etc/nginx/conf.d 将./nginx 复制到/etc/nginx/conf.d 来替换volumes 到我的容器中。问题是因为通过使用值 nginx.conf 引用我的主机中的日志文件而不是我的容器。所以,我想通过将配置文件硬拷贝到容器中来解决我的问题。
然而,NGINX 在docker compose up 根本没有运行。怎么了?
编辑:
Dockerfile
FROM python:3-onbuild
COPY ./ /app
COPY ./nginx /etc/nginx/conf.d
RUN chmod +x /app/start_celerybeat.sh
RUN chmod +x /app/start_celeryd.sh
RUN chmod +x /app/start_web.sh
RUN pip install -r /app/requirements.txt
RUN python /app/manage.py collectstatic --noinput
RUN /app/automation/rm.sh
docker-compose.yml
version: "3"
services:
nginx:
image: nginx:latest
container_name: nginx_airport
ports:
- "8080:8080"
rabbit:
image: rabbitmq:latest
environment:
- RABBITMQ_DEFAULT_USER=admin
- RABBITMQ_DEFAULT_PASS=asdasdasd
ports:
- "5672:5672"
- "15672:15672"
web:
build:
context: ./
dockerfile: Dockerfile
command: /app/start_web.sh
container_name: django_airport
expose:
- "8080"
links:
- rabbit
celerybeat:
build: ./
command: /app/start_celerybeat.sh
depends_on:
- web
links:
- rabbit
celeryd:
build: ./
command: /app/start_celeryd.sh
depends_on:
- web
links:
- rabbit
【问题讨论】:
-
如果您已将卷标签替换为 COPY,则应粘贴 Dockerfile 以全面了解您的问题。
-
@lifeisfoo,对不起,我更新了我的答案。 Dockerfile 是“web”服务的 Dockerfile。它在 NGINX 启动之前加载,所以我想我把它放在那里。
-
看起来你混淆了
web和nginx。如果您想要nginx的自定义图像,则需要单独的Dockerfile-nginx。 -
@schmunk,是吗?好吧,因为 NGINX 只需要
COPY ./nginx /etc/nginx/conf.d我想我可以把和 web 一样的 Dockerfile 放进去。因为无论如何,网络永远是第一位的。 -
@notalentgeek 如果答案解决了您的问题,请接受。所以未来的访客可以认出它。
标签: docker nginx docker-compose