1
Reading Time: < 1 minute
I have some shared env. vars for some containers.
So I want to build ME_CONFIG_MONGODB_URL using these 2 shared vars..
version: "3.7"
x-environment: &commonEnvironment
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: root
services:
mongo:
image: mongo
restart: always
container_name: mongo
ports:
- 27017:27017
environment:
<<: *commonEnvironment
volumes:
- mongo-data:/data/db
networks:
- goboards-net
mongo-express:
image: mongo-express
container_name: mongo_express
restart: always
ports:
- 8081:8081
environment:
<<: *commonEnvironment
ME_CONFIG_MONGODB_URL: mongodb://$MONGO_INITDB_ROOT_USERNAME:[email protected]
networks:
- goboards-net
But while running docker-compose -f docker-compose.prod.yml up –build -d
I am getting
WARNING: The MONGO_INITDB_ROOT_USERNAME variable is not set. Defaulting to a blank string.
WARNING: The MONGO_INITDB_ROOT_PASSWORD variable is not set. Defaulting to a blank string.
WARNING: The ME_CONFIG_MONGODB_URL variable is not set. Defaulting to a blank string.
Nevertheless, mongo have these vars, but mongo-express does not. Cant understand why.
|