2

Despite following numerous tutorials and guides, including official documents, I'm constantly hitting a brick wall when attempting to deploy my docker containers to ECS.

Here's what I've done:

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

My docker-compose.staging.yml is

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

After running the compose command, I get:

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 kindly returns:

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

Just in case, I then ran spun the service up:

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

This took a while, but finally said it was finished:

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

But when checking the process list again, it was filled with duplicates of the attempt above.

After finally connecting to the container instance, I was able to query ecs-agent log but this didn't really contain much info, other than:

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)"

Everything works perfectly fine on Docker without any issues, but new to this part of the devops game, so completely confused as to what could be the issue.

Any suggestions?

Gavin
  • 6,284
  • 5
  • 30
  • 38

2 Answers2

0

I would use terraform to build your Amazon ECS cluster and use the tasks and services to deploy docker containers. If you want to use a more docker compatiable API solution then use docker swarm. Docker compose is more of a local testing tool then an orchestrator for a production environment.

0

Ultimately, I had to use the Elastic Beanstalk Multi-Container environment which worked nicely.

{
  "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"
        }
      ]
    }
  ]
}

Hope this helps anyone with a similar problem!

mcrute
  • 1,592
  • 1
  • 16
  • 27
Gavin
  • 6,284
  • 5
  • 30
  • 38