Невозможно развернуть Docker composer в AWS ECS

Несмотря на то, что я следую многочисленным учебникам и руководствам, включая официальные документы, я постоянно бью кирпичную стену при попытке развернуть мои док-контейнеры в ECS.

Вот что я сделал:

ecs-cli configure --cluster my-cluster
ecs-cli up --keypair XXX --capability-iam --size 1 --instance-type t2.micro
ecs-cli compose --file docker-compose.staging.yml up

мой docker-compose.staging.yml является

version: '2'
services:
    web:
        mem_limit: 128m
        image: nginx:latest
        ports:
            - "80:80"
            - "443:443"
        volumes:
            - src:/var/www
            - vhost.staging.conf:/etc/nginx/conf.d/site.conf
            - certificates:/etc/nginx/ssl
        links:
            - app
        depends_on:
            - app
    app:
        mem_limit: 128m
        image: groberts12/php7.1-fpm-base
        volumes:
            - src:/var/www

После запуска команды compose я получаю:

WARN[0000] Skipping unsupported YAML option...           option name=networks
WARN[0000] Skipping unsupported YAML option for service...  option name=networks service name=app
WARN[0000] Skipping unsupported YAML option for service...  option name="depends_on" service name=web
WARN[0000] Skipping unsupported YAML option for service...  option name=networks service name=web
INFO[0002] Using ECS task definition                     TaskDefinition="ecscompose-docker:5"
INFO[0002] Starting container...                         container="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/app"
INFO[0002] Starting container...                         container="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/web"
INFO[0002] Describe ECS container status                 container="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/web" desiredStatus=RUNNING lastStatus=PENDING taskDefinition="ecscompose-docker:5"
INFO[0002] Describe ECS container status                 container="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/app" desiredStatus=RUNNING lastStatus=PENDING taskDefinition="ecscompose-docker:5"
INFO[0014] Describe ECS container status                 container="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/web" desiredStatus=RUNNING lastStatus=PENDING taskDefinition="ecscompose-docker:5"
INFO[0014] Describe ECS container status                 container="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/app" desiredStatus=RUNNING lastStatus=PENDING taskDefinition="ecscompose-docker:5"
INFO[0026] Describe ECS container status                 container="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/web" desiredStatus=RUNNING lastStatus=PENDING taskDefinition="ecscompose-docker:5"
INFO[0026] Describe ECS container status                 container="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/app" desiredStatus=RUNNING lastStatus=PENDING taskDefinition="ecscompose-docker:5"
INFO[0032] Stopped container...                          container="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/web" desiredStatus=STOPPED lastStatus=STOPPED taskDefinition="ecscompose-docker:5"
INFO[0032] Stopped container...                          container="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/app" desiredStatus=STOPPED lastStatus=STOPPED taskDefinition="ecscompose-docker:5"

ecs-cli ps любезно возвращается:

Name                                      State                Ports                                                   TaskDefinition
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/web  STOPPED ExitCode: 1  xx.xxx.xxx.xxx:443->443/tcp, xx.xxx.xxx.xxx:80->80/tcp  ecscompose-docker:5
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/app  STOPPED ExitCode: 0                                                          ecscompose-docker:5

На всякий случай я тогда побежал раскрутил сервис:

ecs-cli compose --file docker-compose.staging.yml service up

Это заняло какое-то время, но, наконец, сказал, что это было закончено:

WARN[0000] Skipping unsupported YAML option...           option name=networks
WARN[0000] Skipping unsupported YAML option for service...  option name=networks service name=app
WARN[0000] Skipping unsupported YAML option for service...  option name="depends_on" service name=web
WARN[0000] Skipping unsupported YAML option for service...  option name=networks service name=web
INFO[0001] Using ECS task definition                     TaskDefinition="ecscompose-docker:6"
INFO[0001] Created an ECS service                        service=ecscompose-service-docker taskDefinition="ecscompose-docker:6"
INFO[0002] Updated ECS service successfully              desiredCount=1 serviceName=ecscompose-service-docker
INFO[0002] Describe ECS Service status                   desiredCount=1 runningCount=0 serviceName=ecscompose-service-docker
INFO[0032] Describe ECS Service status                   desiredCount=1 runningCount=0 serviceName=ecscompose-service-docker
INFO[0062] Describe ECS Service status                   desiredCount=1 runningCount=0 serviceName=ecscompose-service-docker
INFO[0092] Describe ECS Service status                   desiredCount=1 runningCount=0 serviceName=ecscompose-service-docker
INFO[0122] Describe ECS Service status                   desiredCount=1 runningCount=0 serviceName=ecscompose-service-docker
INFO[0152] Describe ECS Service status                   desiredCount=1 runningCount=0 serviceName=ecscompose-service-docker
INFO[0182] Describe ECS Service status                   desiredCount=1 runningCount=0 serviceName=ecscompose-service-docker
INFO[0212] Describe ECS Service status                   desiredCount=1 runningCount=0 serviceName=ecscompose-service-docker
INFO[0243] Describe ECS Service status                   desiredCount=1 runningCount=0 serviceName=ecscompose-service-docker
INFO[0273] Describe ECS Service status                   desiredCount=1 runningCount=0 serviceName=ecscompose-service-docker
INFO[0303] Describe ECS Service status                   desiredCount=1 runningCount=0 serviceName=ecscompose-service-docker
INFO[0333] Describe ECS Service status                   desiredCount=1 runningCount=0 serviceName=ecscompose-service-docker
INFO[0363] Describe ECS Service status                   desiredCount=1 runningCount=0 serviceName=ecscompose-service-docker
INFO[0378] ECS Service has reached a stable state        desiredCount=1 runningCount=1 serviceName=ecscompose-service-docker

Но при повторной проверке списка процессов он был заполнен дубликатами попытки, указанной выше.

Наконец, после подключения к экземпляру контейнера, я смог запросить журнал ecs-agent, но он не содержал много информации, кроме:

2017-03-29T15:24:11Z [WARN] Warning, link with no linkalias module="api client" linkName="app" task="ecscompose-docker:6 arn:aws:ecs:eu-west-1:571010915057:task/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, Status: (NONE->RUNNING) Containers: [web (PULLED->RUNNING),app (RUNNING->RUNNING),]" container="web(nginx:latest) (PULLED->RUNNING)"

На Docker все работает отлично, без каких-либо проблем, но это новшество в этой части игры devops, настолько запутанное, что может быть проблемой.

Какие-либо предложения?

2 ответа

Я бы использовал terraform для создания кластера Amazon ECS, а также использовал задачи и сервисы для развертывания док-контейнеров. Если вы хотите использовать более совместимое с Docker решение API, используйте Docker Swarm. Docker compose - это скорее инструмент локального тестирования, чем оркестратор для производственной среды.

В конечном итоге мне пришлось использовать многокомпонентную среду Elastic Beanstalk, которая работала хорошо.

{
  "AWSEBDockerrunVersion": 2,
  "volumes": [{
    "name": "php-app",
    "host": {
      "sourcePath": "/var/app/current/src"
    }
  }, {
    "name": "nginx-proxy-conf",
    "host": {
      "sourcePath": "/var/app/current/vhost.staging.conf"
    }
  }, {
    "name": "nginx-ssl-certificates",
    "host": {
      "sourcePath": "/var/app/current/certificates"
    }
  }],
  "containerDefinitions": [
    {
      "name": "app",
      "image": "groberts12/php7.1-fpm-base",
      "environment": [{
        "name": "Container",
        "value": "groberts12/php7.1-fpm-base"
      }],
      "essential": true,
      "memory": 128,
      "mountPoints": [{
        "sourceVolume": "php-app",
        "containerPath": "/var/www"
      }]
    },
    {
      "name": "web",
      "image": "nginx:latest",
      "essential": true,
      "memory": 128,
      "portMappings": [{
        "hostPort": 80,
        "containerPort": 80
      }, {
        "hostPort": 443,
        "containerPort": 443
      }],
      "links": [
        "app"
      ],
      "mountPoints": [{
          "sourceVolume": "php-app",
          "containerPath": "/var/www"
        }, {
          "sourceVolume": "nginx-proxy-conf",
          "containerPath": "/etc/nginx/conf.d/default.conf"
        }, {
          "sourceVolume": "nginx-ssl-certificates",
          "containerPath": "/etc/nginx/ssl"
        }
      ]
    }
  ]
}

Надеюсь, что это поможет любому с подобной проблемой!

Другие вопросы по тегам