我正在使用mysql docker image,这有效:
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=12345678 -d mysql:5.7.21
现在我想把它变成一个docker-compose yml文件:
version: "3"
services:
mysql:
image: mysql:5.7.21
environment:
- MYSQL_ROOT_PASSWORD:12345678
container_name: some-mysql
当docker-compose时,它显示以下错误:
Recreating test-mysql
Attaching to some-mysql
some-mysql | error: database is uninitialized and password option is not specified
some-mysql | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
some-mysql退出代码1
任何想法为什么?
答案 0 :(得分:0)
environment
文件的docker-compose.yaml
块中存在错误。
根据docker compose文档,environment
块应该是:
environment:
- MYSQL_ROOT_PASSWORD=12345678
或
environment:
MYSQL_ROOT_PASSWORD: 12345678