我有一個帶有 Ubuntu 和 Docker 的虛擬機。
我有兩個容器(ASP .NET 6 應用程式和 nginx 服務器)
我的 docker compose 檔案如下所示:
version: '3.9'
services:
nginx:
container_name: nginx
image: nginx
ports:
- "80:80"
depends_on:
- myapp
volumes:
- ./nginx/conf.d/:/etc/nginx/conf.d/
restart: always
myapp:
container_name: myapp
image: <...>
restart: always
volumes:
- logs:/mnt/logs
- data:/mnt/data
volumes:
logs:
data:
當我嘗試連接到埠 80 時,它顯示“連接被拒絕”。
如果我嘗試使用默認的 nginx 配置,則會打開默認的 nginx 頁面。
如果我為 myapp 打開埠 5000,那么我可以在此埠上訪問它。
nginx配置:
server {
listen: 80;
location / {
proxy_pass http://myapp:5000;
}
}
uj5u.com熱心網友回復:
問題已解決:我的組態檔掛載不正確。
正確版本:
<...>
volumes:
- nginx-config:/etc/nginx/conf.d
<...>
volumes:
logs:
data:
nginx-config:
現在我可以更改檔案/var/lib/docker/volumes/coi_nginx-config/_data/default.conf
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/450985.html
