我有一個docker-compose用于部署的 Flask/Svelte 專案。
Docker-compose 看起來像這樣:
version: "3"
services:
backend:
build: ./backend
container_name: backend
restart: on-failure
# env_file: ./backend/.env
# TODO erase ports. only use for tests
ports:
- 5001:5000
frontend:
build: ./frontend
container_name: frontend
restart: on-failure
depends_on:
- backend
nginx:
image: nginx:alpine
container_name: LBA
restart: on-failure
volumes:
- ./nginx/nginx.conf:/etc/nginx
ports:
- 80:80
depends_on:
- backend
- frontend
雖然我frontend/Dockerfile看起來像這樣:
FROM nginx:alpine
EXPOSE 80
COPY ./dist /usr/share/nginx/html
COPY ./nginx.conf /etc/nginx/nginx.conf
專案結構如下所示:
Project
|
|___backend
| |
| |__...
|
|___frontend
| |
| |__...
| |
| |__nginx.conf
|
|___docker-compose.yaml
這會在運行時創建以下輸出:
...
LBA | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf is not a file or does not exist
LBA | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
LBA | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
LBA | /docker-entrypoint.sh: Configuration complete; ready for start up
LBA | 2022/10/13 05:17:22 [emerg] 1#1: open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
LBA | nginx: [emerg] open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
我在我的 docker 配置上弄亂了一些東西嗎?
uj5u.com熱心網友回復:
問題是你的 docker-compose.yml中的這個系結:
volumes:
- ./nginx/nginx.conf:/etc/nginx
您正在將本地./nginx/nginx.conf檔案系結到容器的/etc/nginx,它應該是一個目錄,但改為名為 /etc/nginx 的 nginx.conf。
解決方案是將卷掛載為./nginx/nginx.conf:/etc/nginx/nginx.conf或者./nginx:/etc/nginx如果您想覆寫整個目錄。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/515786.html
標籤:码头工人nginx
上一篇:Nginx:我應該選擇默認配置還是mydomain.conf配置來為服務器中的單個域提供服務?
下一篇:子域的Nginx重定向
