我需要在AWS ECS上部署this project(最好是Fargate或EC2最坏的情况)。
查看documentation,我尝试使用单个容器进行部署,并且可以使用多个容器,但是由于ecs-cli的限制,我无法直接从项目使用docker-compose.yml,因此我将docker镜像上传到ECR,然后创建一个新的docker-compose以及各个conatiner的摘要。
这是原始docker-compose.yml的链接。
将图片上传到ECR之后,这是我的docker-compose的样子:

version: "3.0"
services:
    postgres:
        image: postgres:12
        logging:
            driver: awslogs
            options:
                awslogs-group: aws-ecs-docker-test
                awslogs-region: ap-south-1
                awslogs-stream-prefix: docker

    db:
        image: sha256:123123123123123213213213213
        logging:
            driver: awslogs
            options:
                awslogs-group: aws-ecs-docker-test
                awslogs-region: ap-south-1
                awslogs-stream-prefix: docker

    traefik:
        image: sha256:123123123123123213213213213
        logging:
            driver: awslogs
            options:
                awslogs-group: aws-ecs-docker-test
                awslogs-region: ap-south-1
                awslogs-stream-prefix: docker

    queue:
        image: sha256:123123123123123213213213213
        logging:
            driver: awslogs
            options:
                awslogs-group: aws-ecs-docker-test
                awslogs-region: ap-south-1
                awslogs-stream-prefix: docker

    flower:
        image: sha256:123123123123123213213213213
        env_file:
            - .env
        logging:
            driver: awslogs
            options:
                awslogs-group: aws-ecs-docker-test
                awslogs-region: ap-south-1
                awslogs-stream-prefix: docker

    backend:
        image: sha256:123123123123123213213213213
        env_file:
            - .env
        environment:
            - SERVER_NAME=${DOMAIN?Variable not set}
            - SERVER_HOST=https://${DOMAIN?Variable not set}
            - SMTP_HOST=${SMTP_HOST}
        ports:
            - "80:80"
        logging:
            driver: awslogs
            options:
                awslogs-group: aws-ecs-docker-test
                awslogs-region: ap-south-1
                awslogs-stream-prefix: docker

    celeryworker:
        image: sha256:123123123123123213213213213
        env_file:
            - .env
        environment:
            - SERVER_NAME=${DOMAIN?Variable not set}
            - SERVER_HOST=https://${DOMAIN?Variable not set}
            # Allow explicit env var override for tests
            - SMTP_HOST=${SMTP_HOST?Variable not set}
        logging:
            driver: awslogs
            options:
                awslogs-group: aws-ecs-docker-test
                awslogs-region: ap-south-1
                awslogs-stream-prefix: docker


    frontend:
        image: sha256:123123123123123213213213213
        logging:
            driver: awslogs
            options:
                awslogs-group: aws-ecs-docker-test
                awslogs-region: ap-south-1
                awslogs-stream-prefix: docker

volumes:
  app-db-data:
这是ecs-params.yml:
version: 1
task_definition:
  task_execution_role: ecsTaskExecutionRole
  ecs_network_mode: awsvpc
  task_size:
    mem_limit: 0.5GB
    cpu_limit: 256
run_params:
  network_configuration:
    awsvpc_configuration:
      subnets:
        - subnet-123123123
        - subnet-123123123
      security_groups:
        - sg-123123123
      assign_public_ip: ENABLED
ecsTaskExecutionRole有权访问ECS,ECR和Cloudwatch日志。但是,每当我部署时,ecs都会创建一些任务定义,然后超时:
Deployment has not completed: Running count has not changed for 5.00 minutes
即使我将超时延长到30分钟,它也不会更改输出。日志没有输出任何内容,因此对于潜在的问题我一无所知。
我是Devops&Docker的新手,所以不确定我实际上缺少什么。

最佳答案

我最终能够解决此问题。问题出在traefik镜像上,并且缺乏对IAM角色的Cloudwatch权限。

关于amazon-web-services - 使用ECS-CLI将多容器Docker应用程序部署到AWS ECS Fargate,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/64280604/

10-16 12:25