簡體   English   中英

AWS ECS 容器鏈接:MySQL 連接被拒絕

[英]AWS ECS container linking: MySQL connection refused

我試圖用這個簡單的例子鏈接 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"
}

問題解決:內存設置太低,128對於MySQL來說顯然不夠,WordPress可以處理。 將內存設置為 300 解決了該問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM