6

I have created a Docker containers using docker-compose. In my local environment, i am able to bring up my application without any issues.

Now i wanted to deploy all my docker containers to the AWS EC2 (ECS). After going over the ECS documentation, i found out that we can make use of the same docker-compose to deploy in ECS using ECS-CLI. But ECS-CLI is not available for windows instances as of now. So now i am not sure how to use my docker-compose to build all my images using a single command and deploy it to the ECS from an windows instance.

It seems like i have to deploy my docker containers one by one to ECS as like below steps,

  1. From the ECS Control Panel, create a Docker Image Repository.
  2. Connect your local Docker client with your Docker credentials in ECS:
  3. Copy and paste the Docker login command from the previous step. This will log you in for 24 hours
  4. Tag your image locally ready to push to your ECS repository – use the repo URI from the first step
  5. Push the image to your ECS repoository\
  6. create tasks with the web UI, or manually as a JSON file
  7. create a cluster, using the web UI.
  8. Run your task specifying the EC2 cluster to run on

Is there any other way of running the docker containers in ECS ?

babs84
  • 421
  • 1
  • 10
  • 18
  • 1
    Just start an Ubuntu EC2 instance, install ecs-cli there, deploy your services with your docker-compose file using ecs-cli. When successfully deployed, terminate Ubuntu EC2 instance. – Rafaf Tahsin Nov 01 '17 at 05:05

2 Answers2

3

Docker-Compose is wrong at this place, when you're using ECS.

You can configure multiple containers within a task definition, as seen here in the CloudFormation docs:

ContainerDefinitions is a property of the AWS::ECS::TaskDefinition resource that describes the configuration of an Amazon EC2 Container Service (Amazon ECS) container

Type: "AWS::ECS::TaskDefinition"
Properties: 
  Volumes:
    - Volume Definition
  Family: String
  NetworkMode: String
  PlacementConstraints:
   - TaskDefinitionPlacementConstraint
  TaskRoleArn: String
  ContainerDefinitions:
    - Container Definition

Just list multiple containers there and all will be launched together on the same machine.

StephenKing
  • 36,187
  • 11
  • 83
  • 112
  • Yep. That's correct. I was not aware in the first place when i raised this question. Now i am using the AWS task definition to start my 2 docker containers. But i am having issue in starting the docker container with the help of ECS agent. I am going to create a separate question on that. I will link that question here – babs84 Nov 05 '17 at 21:34
  • Thanks for the feedback. Please use the checkmark to mark this question as solved. Feel free to add additional information that you learned about ECS to help with the topic of the question. – StephenKing Nov 06 '17 at 05:35
  • As i mentioned in my previous comment, i am facing issue in running the task. I have created a separate question for that. https://stackoverflow.com/q/47127132/4435358 . If you can please have a look at that question as well. Thanks again. – babs84 Nov 06 '17 at 05:39
1

I got the same situation as you. One way to resolve this was using the Terraform to deploy our containers as a Task Definitions on AWS ECS.

So, we using the docker-compose.yml to run locally and the terraform is a kind of mirror of our docker-compose on AWS.

Also another option is Kubernetes that you can translate from docker-compose to Kubernetes resources.

Samuel P.
  • 26
  • 3