我正在尝试通过从 EB CLI 运行 Dockerrun.aws.json 文件在 Beanstalk 上生成多容器 Docker WordPress 部署。这是我的 Dockerrun:
{
"AWSEBDockerrunVersion": 2,
"containerDefinitions": [
{
"name": "mariadb",
"image": "mariadb:latest",
"essential": true,
"memory": 128,
"portMappings": [
{
"hostPort": 3306,
"containerPort": 3306
}
],
"environment": [
{
"name": "MYSQL_USERNAME",
"value": "root"
},
{
"name": "MYSQL_PASSWORD",
"value": "password"
},
{
"name": "MYSQL_DB_NAME",
"value": "wordpress"
}
]
},
{
"name": "wordpress",
"image": "wordpress",
"essential": true,
"memory": 128,
"portMappings": [
{
"hostPort": 80,
"containerPort": 80
}
],
"links": [
"mariadb"
],
"environment": [
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "password"
}
]
}
]
}
Beanstalk 环境正确启动,我可以浏览到端点并开始 WordPress 配置,但它从未连接到 MariaDB。当我通过 SSH 进入主机实例时,我可以看到 WordPress 和 MariaDB 容器都在反复启动 - 并且失败。主机上的 /var/log/containers/ 中有多个 mariadb-* 日志文件,所有文件都包含以下文本:
error: database is uninitialized and password option is not specified
You need to specify one of MYSQL_ROOT_PASSWORD,
MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
我猜是密码没能通过。有什么想法吗?谢谢
答案1
解决方案很简单。我使用的语法是错误的。我最初使用:
"name": "MYSQL_DB_NAME"
但它应该是:
"name": "MYSQL_DATABASE"