Trouble deploying docker on AWS with ecs-cli

2020-03-15 01:37发布

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条回答
祖国的老花朵
2楼-- · 2020-03-15 02:00

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

查看更多
Ridiculous、
3楼-- · 2020-03-15 02:09

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.

查看更多
登录 后发表回答