这是我的docker-compose.yml:
version: "3"
services:
mongodb:
image: mongo:4.1
volumes:
- ./mongodb_data:/data/db
container_name: mongodb
ports:
- 27017:27017
mysql:
image: mysql:5.7
#volumes:
#- ./mysql_data:/var/lib/mysql
container_name: mysqldb
ports:
- 3306:3306
- 33060:33060
expose:
- 3306
- 33060
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=somedb
- MYSQL_USER=rstudio
- MYSQL_PASSWORD=password
healthcheck:
test: ["CMD", "mysql", "--user=$MYSQL_USER", "--password=$MYSQL_PASSWORD", "-e", "'SHOW DATABASES;'"]
timeout: 5s
retries: 5
如何使用环境变量MYSQL_USER和MYSQL_PASSWORD?在当前设置中,运行docker compose时收到以下警告:
WARNING: The MYSQL_USER variable is not set. Defaulting to a blank string.
WARNING: The MYSQL_PASSWORD variable is not set. Defaulting to a blank string.