AWS ECS container linking: MySQL connection refused
<p>I'm trying to link two containers in Amazon ECS (Container Service) with this simple example: <a href="http://docs.aws.amazon.com/AmazonECS/latest/developerguide/example_task_definitions.html" rel="nofollow">http://docs.aws.amazon.com/AmazonECS/latest/developerguide/example_task_definitions.html</a></p>

<p>For what ever reason the WordPress container can't access the MySQL Database and from the logs of the WordPress Container I see the following:</p>

<p><code>Warning: mysqli::mysqli(): (HY000/2002): Connection refused in - on line 10</code></p>

<p>It says on <a href="https://hub.docker.com/_/wordpress/" rel="nofollow">DockerHub</a> that the WordPress container will automatically get the Root PW and the HOST IP from the linked container, so why am I facing this problem.</p>

<p>My JSON Config looks like this:</p>

<pre><code>{
  "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"
}
</code></pre>