使用docker composer在AWS beanstalk上部署docker

Lin*_*ang 11 amazon-web-services amazon-ecs docker amazon-elastic-beanstalk docker-compose

我正在尝试在AWS beanstalk上部署多个node.js微服务,我希望它们部署在同一个实例上.这是我第一次部署多项服务,所以有些失败我需要有人来帮助我.所以,我首先尝试将它们打包到docker容器中.同时我正在使用docker composer来管理结构.它在我的虚拟机中启动并运行,但是当我将它部署到beanstalk时,我遇到了一些问题.

我知道的:

  1. 我知道我必须选择部署为多容器泊坞机.
  2. 管理多个node.js服务的最佳实践是使用docker composer.
  3. 我需要一个dockerrun.aws.jsonfor node.js应用程序.
  4. 我需要为该ecs实例创建任务定义.

哪里有问题:

  1. 我只能找到dockerrun.aws.jsontask_definition.json PHP的模板,所以我无法验证,如果我在这两个JSON文件Node.js的配置都在正确的形状.
  2. 看来docker-compose.yml,dockerrun.aws.json并且task_definition.json正在做类似的工作.我必须保持task_definition,但是我还需要dockerrun.aws.json吗?
  3. 我试图在ecs中运行任务,但它立即停止了.如何查看日志以查找任务?

我有:

在环境中找不到ecs任务定义(或空定义文件)

因为我的任务将永远停止.如果我可以查看日志,我会更容易进行故障排除.

这是我的task_definition.json:

{
  "requiresAttributes": [],
  "taskDefinitionArn": "arn:aws:ecs:us-east-1:231440562752:task-definition/ComposerExample:1",
  "status": "ACTIVE",
  "revision": 1,
  "containerDefinitions": [
    {
      "volumesFrom": [],
      "memory": 100,
      "extraHosts": null,
      "dnsServers": null,
      "disableNetworking": null,
      "dnsSearchDomains": null,
      "portMappings": [
        {
          "hostPort": 80,
          "containerPort": 80,
          "protocol": "tcp"
        }
      ],
      "hostname": null,
      "essential": true,
      "entryPoint": null,
      "mountPoints": [
        {
          "containerPath": "/usr/share/nginx/html",
          "sourceVolume": "webdata",
          "readOnly": true
        }
      ],
      "name": "nginxexpressredisnodemon_nginx_1",
      "ulimits": null,
      "dockerSecurityOptions": null,
      "environment": [],
      "links": null,
      "workingDirectory": null,
      "readonlyRootFilesystem": null,
      "image": "nginxexpressredisnodemon_nginx",
      "command": null,
      "user": null,
      "dockerLabels": null,
      "logConfiguration": null,
      "cpu": 99,
      "privileged": null
    }
  ],
  "volumes": [
    {
      "host": {
        "sourcePath": "/ecs/webdata"
      },
      "name": "webdata"
    }
  ],
  "family": "ComposerExample"
}
Run Code Online (Sandbox Code Playgroud)

sim*_*uin 8

我有一个类似的问题,结果我直接在Archive.zip文件中存档包含文件夹,从而在Archive.zip文件中给我这个结构:

RootFolder
    - Dockerrun.aws.json
    - Other files...
Run Code Online (Sandbox Code Playgroud)

事实证明,通过仅归档RootFolder的内容(而不是文件夹本身),Amazon Beanstalk识别出ECS任务定义文件.

希望这可以帮助.