version: "3.3"
services:
mongodb:
image: mongo:latest
container_name: "mongo"
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: rootpassword
ports:
- 27017:27017
mongo-express:
image: mongo-express:latest
container_name: mongoexpressweb
environment:
- ME_CONFIG_OPTIONS_EDITORTHEME=ambiance
- ME_CONFIG_MONGODB_ENABLE_ADMIN=true
- ME_CONFIG_MONGODB_AUTH_DATABASE=admin
- ME_CONFIG_MONGODB_AUTH_USERNAME=root
- ME_CONFIG_MONGODB_AUTH_PASSWORD=rootpassword
- ME_CONFIG_MONGODB_ADMINUSERNAME=root
- ME_CONFIG_MONGODB_ADMINPASSWORD=rootpassword
- ME_CONFIG_BASICAUTH_USERNAME=root
- ME_CONFIG_BASICAUTH_PASSWORD=root
ports:
- 8081:8081
links:
- mongodb
depends_on:
- mongodb
我已经像上面那样编写了我的 docker-compose.yaml 文件。两者都在之后运行。但是,mongo-express 出现 403 禁止错误。当我检查 Visual Studio 代码中的视图日志时。我看到这个错误:
Waiting for mongo:27017...
Waiting for mongo:27017...
/docker-entrypoint.sh: connect: Connection refused
/docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Connection refused
Fri Feb 21 07:32:10 UTC 2020 retrying to connect to mongo:27017 (2/5)
/docker-entrypoint.sh: connect: Connection refused
/docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Connection refused
Fri Feb 21 07:32:11 UTC 2020 retrying to connect to mongo:27017 (3/5)
/docker-entrypoint.sh: connect: Connection refused
/docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Connection refused
Fri Feb 21 07:32:12 UTC 2020 retrying to connect to mongo:27017 (4/5)
/docker-entrypoint.sh: connect: Connection refused
/docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Connection refused
Fri Feb 21 07:32:13 UTC 2020 retrying to connect to mongo:27017 (5/5)
/docker-entrypoint.sh: connect: Connection refused
/docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Connection refused
Welcome to mongo-express
------------------------
Mongo Express server listening at http://0.0.0.0:8081
Server is open to allow connections from anyone (0.0.0.0)
Database connected
Admin Database connected