gpt4 book ai didi

amazon-web-services - 使用 docker composer 在 AWS beanstalk 上部署 docker

转载 作者:IT老高 更新时间:2023-10-28 12:46:22 26 4
gpt4 key购买 nike

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

我知道的:

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

我有问题的地方:

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

我明白了:

No ecs task definition (or empty definition file) found in environment

因为我的任务总是会立即停止。如果我可以查看日志,我将更容易进行故障排除。

这是我的 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"
}

最佳答案

我遇到了类似的问题,结果我将包含文件夹直接存档在我的 Archive.zip 文件中,因此在 Archive.zip 文件中给了我这个结构:

RootFolder
- Dockerrun.aws.json
- Other files...

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

希望这会有所帮助。

关于amazon-web-services - 使用 docker composer 在 AWS beanstalk 上部署 docker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37794723/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com