如何访问 docker-compose 文件中的 entrypoint.sh 值。我已经声明了 entrypoint.sh 中的所有值,如下所示。我需要访问我的 docker-compose 文件中的那些
我使用 docker-volumes 将 entrypoint.sh 脚本复制到 docker 容器中的 /usr/local/bin 目录。
entrypoint.sh 脚本
MONGO_ROOT_USERNAME=root
MONGO_ROOT_PASSWORD=mongo@123
MONGO_EXPRESS_USERNAME=root
MONGO_EXPRESS_PASSWORD=express@123
码头工人撰写文件
mongo-express:
image: mongo-express
ports:
- 8081:8081
volumes:
- "./docker-scripts/entrypoint.sh:/usr/local/bin"
environment:
ME_CONFIG_BASICAUTH_USERNAME: ${MONGO_EXPRESS_USERNAME}
ME_CONFIG_BASICAUTH_PASSWORD: ${MONGO_EXPRESS_PASSWORD}
ME_CONFIG_MONGODB_PORT: 27017
ME_CONFIG_MONGODB_ADMINUSERNAME: ${MONGO_ROOT_USERNAME}
ME_CONFIG_MONGODB_ADMINPASSWORD: ${MONGO_ROOT_PASSWORD}
但是当我运行 docker-compose -d 我收到这条消息
WARNING: The MONGO_ROOT_USERNAME variable is not set. Defaulting to a blank string.
WARNING: The MONGO_ROOT_PASSWORD variable is not set. Defaulting to a blank string.
WARNING: The MONGO_EXPRESS_USERNAME variable is not set. Defaulting to a blank string.
WARNING: The MONGO_EXPRESS_PASSWORD variable is not set. Defaulting to a blank string.