我正在尝试使用mongo和mongo-express部署堆栈。我希望它们都能从我的主机上获得。这是为了能够连接到mongo db并访问mongo-express web界面。
我有以下stack.yml
:
version: '3.1'
services:
mongo:
image: mongo
ports:
- 27017:27017
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
mongo-express:
image: mongo-express
ports:
- 8081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: example
可以从我的主机访问mongo
实例,但不能访问Web界面。它只是试图永远地连接。
答案 0 :(得分:0)
The problem that I can think of is more related to service startup order.
Try following operations
#>docker-compose -f stack.yml up --no-start
#>docker-compose -f stack.yml start mongo
#>docker-compose -f stack.yml start mongo-express
The main issue is that mongo-express is try to connect to mongo and at that time mongo was not completely started or ready to connect and that's why mongo-express quickly exited.
In order to specify order take a look at following articles.
https://docs.docker.com/compose/compose-file/#depends_on https://docs.docker.com/compose/startup-order/