AWS ECS容器链接:MySQL连接被拒绝

时间:2016-03-19 13:59:08

标签: amazon-web-services amazon-ec2 amazon-ecs

我正在尝试使用以下简单示例链接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"
}

1 个答案:

答案 0 :(得分:1)

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