【发布时间】:2018-01-16 20:08:42
【问题描述】:
我正在使用以下 compose 文件运行两个 centos docker 容器-
version: "2"
services:
nginx:
build:
context: ./docker-build
dockerfile: Dockerfile.nginx
restart: always
ports:
- "8080:8080"
command: "/usr/sbin/nginx"
volumes:
- ~/my-dir:/my-dir
data:
build:
context: ./docker-build
dockerfile: Dockerfile.data
restart: always
ports:
- "8081:8081"
command: "/usr/sbin/nginx"
volumes:
- ~/my-dir-1:/my-dir-1
我已经在两个容器中使用 Dockerfile 安装了 nginx 以访问特定目录。
尝试使用 nginx 将请求 http://host-IP:8080/my-data/ 重定向到 data 容器。
下面是我对nginx 容器的 Nginx 配置
/etc/nginx/conf.d/default.conf
server {
listen 8080;
location / {
root /my-dir/;
index index.html index.htm;
}
}
我可以使用http://host-IP:8080 URL 和my-dir-1 使用http://host-IP:8081 URL 访问my-dir 目录,如何配置Nginx 以使用data 容器重定向请求http://host-IP:8080/my-data URL
【问题讨论】:
标签: linux docker docker-compose devops docker-swarm