我的
version: '3'
services:
nginx:
restart: always
build: ./nginx/
depends_on:
- web
ports:
- "8000:8000"
network_mode: "host" # Connection between containers
web:
build: .
image: app-image
ports:
- "80:80"
volumes:
- .:/app-name
command: uwsgi /app-path/web/app.ini
upstream web {
server 0.0.0.0:80;
}
server {
listen 8000;
server_name web;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
alias "/app-static/";
}
location / {
proxy_pass http://web;
}
}
所以基本上我在一个容器'web'中有Django和uWSGI,在容器'NGINX'中有NGINX。我通过代理使用NGINX链接两者,两者都很好。(不知何故我需要“网络模式:”“主机”’,没有它就不行了)
因为它们是不同的容器,所以我不能使用.sock文件(除非我使用一些卷破解来共享.sock文件,这是不好的!)
尽管这是可行的,但我被要求避免通过代理使用NGINX,那么有没有其他方法来连接这两者?