我有两个对接图像,1)用于couchdb和2)一个web应用程序。web应用程序无法与运行在同一台机器上的couchdb对话。
当我直接访问couchdb时,它正在运行utils/#数据库/ utils/#数据库/。
我漏掉了什么指点?
| Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:5984 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
hashgraph_1 | at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159)
hashgraph_1 | at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
hashgraph_1 | at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
hashgraph_1 | at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
hashgraph_1 | at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
hashgraph_1 | at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
hashgraph_1 | at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
hashgraph_1 | at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
hashgraph_1 | at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
hashgraph_1 | at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)我的船坞撰写文件
version: "3"
services:
hashgraph:
build: "./"
depends_on:
- couchdb
deploy:
replicas: 1
restart_policy:
condition: always
ports:
- "51200-51299:51200-51299"
couchdb:
image: couchdb:2.1
ports:
- "5984:5984"
deploy:
replicas: 1
restart_policy:
condition: always船坞输出ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cc7e37cd6260 hashgraphexperiments_hashgraph "java -jar swirlds.j…" About a minute ago Up About a minute 50200-50299/tcp, 0.0.0.0:51200-51299->51200-51299/tcp hashgraphexperiments_hashgraph_1
9f4767b36aea couchdb:2.1 "tini -- /docker-ent…" 2 hours ago Up About a minute 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp hashgraphexperiments_couchdb_1发布于 2018-03-14 05:26:32
depends_on:它只是等待另一个容器启动。
每当您想从couchdb容器代码调用hashgraph时,都需要使用couchdb:5984而不是localhost:5984
您还可以显式地使用links条目而不是depends_on。
对链接的描述是
链接:链接到另一个服务中的容器。要么指定服务名称和链接别名( service :别名),要么只指定服务名称。
链接还以与depends_on相同的方式表示服务之间的依赖关系,因此它们决定服务启动的顺序。
version: "3"
services:
hashgraph:
build: .
links:
- couchdb:couchdb
deploy:
replicas: 1
restart_policy:
condition: always
ports:
- "51200-51299:51200-51299"
couchdb:
image: couchdb:2.1
ports:
- 5984:5984
deploy:
replicas: 1
restart_policy:
condition: alwayshttps://stackoverflow.com/questions/49270225
复制相似问题