【发布时间】:2017-07-18 14:14:31
【问题描述】:
刚开始,我见过this。但是他/她使用build,而我使用image。
我有一个 docker-compose 文件,它将我之前制作的图像拉到我的服务器上。
app:
restart: always
image: some-app-image:latest
nginx 配置
location /static/ {
root /data/app/web_interface; <--- this exists in some-app-image container
}
通常,我会在包含静态文件的应用映像上安装一个卷。
但是,这变得多余,因为应用程序容器本身就有静态文件。
所有 nginx 容器需要做的就是“对等”到应用程序容器并提供这些静态文件。喜欢:
location /static/ {
root http://app:8000/web_interface;
}
或
location /static/ {
root app/web_interface;
}
有没有办法从 nginx 容器中提供位于另一个容器中的静态文件?
【问题讨论】:
-
您的容器设置有点不清楚。您有一个 nginx 容器作为反向代理,已经从您的
app容器(虚拟主机)提供数据?为什么app容器不能提供自己的静态文件? -
我让 nginx 提供静态文件,因为我不希望 gunicorn 服务器处理它们。 stackoverflow.com/a/13947418/5779280
-
要明确一点:应用程序容器运行 gunicorn,而您的 nginx 容器通过 uwsgi_pass 提供服务?
-
或多或少,具体来说是
proxy_pass。