2

我正在尝试使用这个简单的示例链接 Amazon ECS(容器服务)中的两个容器:http: //docs.aws.amazon.com/AmazonECS/latest/developerguide/example_task_definitions.html

无论出于何种原因,WordPress 容器无法访问 MySQL 数据库,并且从 WordPress 容器的日志中我看到以下内容:

Warning: mysqli::mysqli(): (HY000/2002): Connection refused in - on line 10

DockerHub上说 WordPress 容器会自动从链接的容器中获取 Root PW 和 HOST IP,所以我为什么会遇到这个问题。

我的 JSON 配置如下所示:

{
  "requiresAttributes": [],
  "taskDefinitionArn": "arn:aws:ecs:us-east-1:996820535158:task-definition/wordpress-task:2",
  "status": "ACTIVE",
  "revision": 2,
  "containerDefinitions": [
    {
      "volumesFrom": [],
      "memory": 128,
      "extraHosts": null,
      "dnsServers": null,
      "disableNetworking": null,
      "dnsSearchDomains": null,
      "portMappings": [
        {
          "hostPort": 8080,
          "containerPort": 80,
          "protocol": "tcp"
        }
      ],
      "hostname": null,
      "essential": true,
      "entryPoint": null,
      "mountPoints": [],
      "name": "wordpress",
      "ulimits": null,
      "dockerSecurityOptions": null,
      "environment": [],
      "links": [
        "mysql:mysql"
      ],
      "workingDirectory": null,
      "readonlyRootFilesystem": null,
      "image": "wordpress",
      "command": null,
      "user": null,
      "dockerLabels": null,
      "logConfiguration": null,
      "cpu": 500,
      "privileged": null,
      "expanded": false
    },
    {
      "volumesFrom": [],
      "memory": 128,
      "extraHosts": null,
      "dnsServers": null,
      "disableNetworking": null,
      "dnsSearchDomains": null,
      "portMappings": [],
      "hostname": null,
      "essential": true,
      "entryPoint": null,
      "mountPoints": [],
      "name": "mysql",
      "ulimits": null,
      "dockerSecurityOptions": null,
      "environment": [
        {
          "name": "MYSQL_ROOT_PASSWORD",
          "value": "root"
        }
      ],
      "links": null,
      "workingDirectory": null,
      "readonlyRootFilesystem": null,
      "image": "mysql:latest",
      "command": null,
      "user": null,
      "dockerLabels": null,
      "logConfiguration": null,
      "cpu": 500,
      "privileged": null,
      "expanded": false
    }
  ],
  "volumes": [],
  "family": "wordpress-task"
}
4

1 回答 1

1

问题已解决:内存设置太低,128 显然不够 MySQL,WordPress 可以处理。将内存设置为 300 解决了这个问题。

于 2016-03-20T23:47:53.807 回答