在Visual Studio中的docker-compose.yml文件中设置networking的最佳方法?

我想要做的是创build类似于以下内容的Web应用程序堆栈:

http://172.68.54.44/web http://172.68.54.44/api

所以在我的两个项目中,我可以通过“/ api”或“/ web”来引用它们。

以下是我的docker-compose.yml文件。

version: '3' services: web: image: web build: context: ./Web dockerfile: Dockerfile depends_on: - api api: image: api build: context: ./API dockerfile: Dockerfile 

我试图定义我自己的networking,当我尝试在Visual Studio 2017中编译这个,我得到一个错误。 也许我做错了,但我的理解是,每个服务将产生自己的容器。 这两个容器都在主机映像上。 我应该在两种服务上设置相同的图像吗?

任何帮助,这是非常感谢!

Docker本身不提供基于URL信息将请求路由到容器的function(第7层)。

合并应用程序的一种方法是拥有运行某种Web代理的第三个容器。 第三个容器监听所有的web请求,然后将/webpath请求转发到web容器,并请求/apiapi容器。

Traefik , HAProxy ,Apache http,Nginx,Varnish,Squid都支持这种types的请求路由,每个都有自己的附加function。 我不确定是否有任何可用于本地Windows容器。

 version: '3' services: proxy: image: haproxy ports: - '80:80' - '443:443' web: image: web build: context: ./Web dockerfile: Dockerfile depends_on: - api api: image: api build: context: ./API dockerfile: Dockerfile 

HAProxyconfiguration:

 frontend http-in bind :80 acl its_an_api_request path_beg /api acl its_a_web_request path_beg /web use_backend api_server if its_an_api_request use_backend web_server if its_a_web_request default_backend web_server backend api_server server api_1 api:80 backend web_server server web_1 web:80