2016-09-23 208 views
0

我有一個nginx路由到兩個應用程序容器。碼頭集裝箱連接

我在一個容器中運行的登錄應用程序 - account.myproduct.local

我的其他應用程序在其他容器中運行 - calendar.myproduct.local

如果請求被髮到calendar.practo.local它使一個OpenID身份驗證重定向到account.myproduct.local

問題: 我已經鏈接的容器,但由於account.myproduct.local是不是從日曆容器解析(卡爾ndar.myproduct.local),登錄不會發生。 我應該如何解決?

回答

0

您可以使用link命令將別名添加到calendar.myproduct.local的/ etc/hosts中。您的日曆鏈接會是這樣的:

--link account_container_name:account.myproduct.local

這樣calendar.myproduct.local將能夠解析主機名account.myproduct.local而不必知道它的IP。

+0

account.myproduct.local通過通過nginx容器的代理解析。我應該在這種情況下鏈接nginx然後,它會工作嗎? ' - 鏈接nginx:account.myproduct.local'。另外我聽說docker1.9鏈接已被棄用,docker有自己的網絡應該使用。如何使用它? –

+0

添加帶點的鏈接不起作用! services.calendar.links包含無效類型,它應該是一個字符串 services.accounts.links包含一個無效類型,它應該是一個字符串 –

+0

它的Github代碼 - https://github.com/alok87/dockerex –

0

已解決 隨着碼頭版本1.10及以上。不需要鏈接容器,因爲docker-compose創建默認網絡,所有服務都可以通過容器名稱發現。將服務名稱更改爲nginx服務器名稱解決了我的問題。

現在accounts.myproduct.local和calendar.myproduct.local是可解析的從外部(coz of the /etc/hosts in my mac),並且也可分辨內部通信(using the service name which is resolvable in the same network

詳細地正確例如:https://github.com/alok87/dockerex

新搬運工 - 構成文件:

version: '2' 

services: 
    accounts.myproduct.local: 
    build: accounts 

    calendar.myproduct.local: 
    build: calendar 

    router: 
    build: router 
    ports: 
    - 80:80