我的docker-compose.yml
文件如下所示:
version: '3.7'
networks:
myNetwork:
volumes:
mongo_data:
services:
db:
image: mongo
restart: always
networks:
- myNetwork
volumes:
- mongo_data:/data/db
ports:
- "27017:27017"
mongoExpress:
image: mongo-express
networks:
- myNetwork
ports:
- "8081:8081"
environment:
- ME_CONFIG_MONGODB_SERVER=<db-container-name>
depends_on:
- db
为了mongo-express
工作,我需要能够将db
/mongo
容器名称传递给它。有没有办法用compose来实现这一点?