9
votes

I have a repo on ECS, have created a cluster using ecs-cli

ecs-cli configure --region=us-west-2 --profile=<MY PROFILE> --cluster=cluster-1

ecs-cli up --capability-iam --keypair=<MY KEYPAIR>

but then the next step to execute the compose file is when it fails

ecs-cli compose --file docker-compose.yml --project-name drafter-project service up

Here's my docker-compose.yml file:

version: '2'
services:
  rabbit:
    image: rabbitmq
    hostname: rabbit1
    ports:
       - 5672:5672
       - 15672:15672
  drafter:
    build: .
    depends_on: 
      - rabbit

the errors i get here are:

Error registering task definition 
error=ClientException: Container.image should not be null or empty.
Create task definition failed 
error=ClientException: Container.image should not be null or empty.

I'm not sure what task definitions are or what it needs.

2
Note ecs-cli compose and docker compose are not identical, so you should double-check the syntax for ecs and your yaml file. (Sanity check - I assume your config file does actually end in .yaml?) - ldg
Services and tasks are essential component of ecs. You should be able to find documentation for the same on ecs service. The ecs-cli compose is supposed to create the tasks and definitions for you. From the error it seems like ecs, is finding the container image to be null.. can you add your docker compose yml.. Note: ECS cli compose does not support compose version 2 and only supports a subset of docker compose 1 commands. Here is the documentations: docs.aws.amazon.com/AmazonECS/latest/developerguide/… - Shibashis
docs.docker.com/compose/compose-file/#versioning has the documentation and sample for version 1 - Shibashis
Build and upload the image to ecr before executing the CLI command. There is no other option. You can use ECR or docker hub to host the image. - Shibashis
@Shibashis So, there is no way to build locally your images and tell ecs-cli to pull them from there? - Ernesto Cejas

2 Answers

9
votes

From what I understand, ecs-cli has a very limited support of the complete Docker Compose file syntax. For example, you should see warnings about WARN[0000] Skipping unsupported YAML option for service... option name=build service name drafter

The reason is version of ecs-cli you're using is expecting all services to be images. Thus, drafter needs an image, which you can generate via docker build or a traditional docker-compose call (but then you'll need to maintain two versions of the compose file -- the traditional one and the ecs compatible one.

Note: it sounds like they may plan for build support in the future, at least according to one github comment I saw earlier (sorry, already closed the tab, so can't link to it).

4
votes

The problem is in your compose file:

drafter:
    build: .

that will not work, you should first build and push the image:

docker build -t drafter .
docker tag drafter:latest somepath.amazonaws.com/drafter:latest
docker push somepath.amazonaws.com/drafter:latest

so after that do:

drafter:
    image: somepath.amazonaws.com/drafter:latest

note that latest could be also a version.