这是我基本的NGINX设置,可以正常工作!
web:
image: nginx
volumes:
- ./nginx:/etc/nginx/conf.d
....
我通过将./nginx
复制到/etc/nginx/conf.d
,使用COPY ./nginx /etc/nginx/conf.d
替换了volumes
。问题是,使用值时,nginx.conf将引用主机上的日志文件,而不是容器中的文件。因此,我认为通过将配置文件硬拷贝到容器中,可以解决我的问题。然而,在
docker-compose up
时,NGINX根本没有运行。出了什么问题?编辑后的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
web
和nginx
搞混了。如果你想要一个自定义的nginx
镜像,你需要为它准备一个单独的Dockerfile-nginx
文件。 - schmunkCOPY ./nginx /etc/nginx/conf.d
,所以我认为我可以将其放在与web相同的Dockerfile中。因为无论如何web始终是第一个。 - notalentgeek