<p>AWS container service team member here. IF you are still early on in your journey to automate this via a CLI I would suggest you consider moving past the <code>ecs-cli</code>. The follow-on version of this CLI is called <a href="https://aws.github.io/copilot-cli/" rel="nofollow noreferrer">AWS Copilot</a> and has more sophistication to implement those workflows. Note that Copilot dropped support for <code>docker compose</code> because we have implemented a native integration with Docker and the new <code>docker compose cli</code>. You can read more <a href="https://aws.amazon.com/blogs/containers/deploy-applications-on-amazon-ecs-using-docker-compose/" rel="nofollow noreferrer">here</a> and <a href="https://aws.amazon.com/blogs/containers/automated-software-delivery-using-docker-compose-and-amazon-ecs/" rel="nofollow noreferrer">here</a>.</p>

CC BY-SA 4.0
2021-04-21T14:23:11.920Z
Thank you! Copilot seems like it could help me alot. Do you know a noob-friendly guide launching a docker compose project with AWS Copilot? Containers are very new for me so I could not really understand how I would use the info in the links you attached in Copilot.
Felix Eklöf
CC BY-SA 4.0
2021-04-22T06:55:00.727Z
Yes sorry, pointing to the root of the docs may be too overwhelming :) You may want to start with [this one from the docs](https://aws.github.io/copilot-cli/docs/getting-started/first-app-tutorial/) .... or with [this one from the blogs](https://aws.amazon.com/blogs/containers/introducing-aws-copilot/) for a more step-by-step first guided experience.
mreferre
CC BY-SA 4.0
2021-04-22T06:57:56.733Z
But I'd like to hear more from you if either fits your need (as someone completely new to container and of course Copilot) or if you need something different (care to elaborate more on what exactly?). Thanks!
mreferre
CC BY-SA 4.0
2021-04-22T07:40:01.113Z
Thank you very much! Basically I have a web-app I've made in Django. I'm running this project with Django, Gunicorn and Nginx. I've split this in two containers, One with Django files and running gunicorn and the second with Nginx. I also have a `docker-compose.yml` that just point to the images. My goal is basically to have some pipeline so that when I use `git push` some tests will run and the automatically deploy my containers. Right now I have automatic testing and pushing of images to my ECR registry. But the last step of autodeploy is where I'm stuck. Do you think Co-pilot is a good fit?
Felix Eklöf
CC BY-SA 4.0
2021-04-22T08:21:04.290Z
I think the answer to your question is a function of two things: 1) how much you rely on your docker compose file and 2) your view on IaC. If you consider compose an implementation detail you don't have strong opinions about and you like the idea of a simple CLI operational model then Copilot is a great fit. If, however, compose is central to your strategy and you want to use Git as your mechanism to track your infrastructure deployment then the Docker Compose / ECS integration I linked in my original post could be a better approach. Makes sense?
mreferre
CC BY-SA 4.0
2021-04-22T10:18:55.297Z
I think I got my project to work using the method described in the link in your initial post! I really appreciate you taking the time to help me, thank you!
Felix Eklöf
CC BY-SA 4.0
2021-04-22T10:54:44.330Z
Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/123290/discussion-between-felix-eklof-and-mreferre).
Felix Eklöf
CC BY-SA 4.0
2021-04-21T13:38:11.957Z
2021-04-21T13:38:11.957Z
mreferre
<p>I've setup a cluster on AWS ECS, it's hosting nginx and a webapp.</p>
<p>I've used these commands to create my resources</p>
<pre><code>aws ecr create-repository --repository-name &lt;repo-name&gt;

ecs-cli configure --cluster &lt;cluster-name&gt; --region eu-west-3 --config-name &lt;conf-name&gt; --cfn-stack-name &lt;stack-name&gt; --default-launch-type EC2

ecs-cli up --keypair &lt;keypair&gt; --capability-iam --size 1 --instance-type t2.medium --cluster-config &lt;conf-name&gt;

docker-compose build

docker-compose push

ecs-cli compose up --cluster-config &lt;conf-name&gt;
</code></pre>
<p>I've also setup a service in that cluster connected to the task created above.</p>
<p>My goal is to be able to push the docker images (That already works) and then use some command to get ECS to fetch the new images and load them up (this is where I'm stuck). I have to do this through the CLI since I want to automate this later on.</p>
<p>My question is:
Should I just delete the running task so that the service will replace it? This works if I do it in the AWS Management console. But it causes downtime of my webservice.</p>
<p>Another options is to use the command below which I found <a href="https://stackoverflow.com/questions/34840137/how-do-i-deploy-updated-docker-images-to-amazon-ecs-tasks">here</a>:</p>
<pre><code>aws ecs update-service --cluster &lt;cluster name&gt; --service &lt;service name&gt; --force-new-deployment
</code></pre>
<p>However, when I run that command I get this error:</p>
<pre><code>EVENTS  2021-04-21T05:32:45.842000-07:00        2c47e2c0-3a76-4dc1-bfef-21392b65871b    (service &lt;service-name&gt;) was unable to place a task because no container instance met all of its requirements. The closest matching (container-instance 25785de8f80041e0afd7b0adfda5f2fa) is already using a port required by your task. For more information, see the Troubleshooting section of the Amazon ECS Developer Guide.
EVENTS  2021-04-21T05:29:11.592000-07:00        4279fb7c-9c36-477b-acb3-173edb8e2c31    (service &lt;service-name&gt;) has reached a steady state.
</code></pre>
<p>I'm guessing it can't create another EC2 instance because I've set the number of instances to 1 on creation of my cluster. But I tried with 2 instances and it seems overkill to have two instances up and running all the time. How can I achieve this?</p>

<docker><amazon-web-services><amazon-ecs><aws-ecr>
AWS ECS Update with new docker image
Felix Eklöf
# AWS ECS Update with new docker image

(Asked by: username_0 on 2021-04-21)

I've setup a cluster on AWS ECS, it's hosting nginx and a webapp.
I've used these commands to create my resources
aws ecr create-repository --repository-name 

ecs-cli configure --cluster  --region eu-west-3 --config-name  --cfn-stack-name  --default-launch-type EC2

ecs-cli up --keypair  --capability-iam --size 1 --instance-type t2.medium --cluster-config 

docker-compose build

docker-compose push

ecs-cli compose up --cluster-config 

I've also setup a service in that cluster connected to the task created above.
My goal is to be able to push the docker images (That already works) and then use some command to get ECS to fetch the new images and load them up (this is where I'm stuck). I have to do this through the CLI since I want to automate this later on.
My question is:
Should I just delete the running task so that the service will replace it? This works if I do it in the AWS Management console. But it causes downtime of my webservice.
Another options is to use the command below which I found here:
aws ecs update-service --cluster  --service  --force-new-deployment

However, when I run that command I get this error:
EVENTS  2021-04-21T05:32:45.842000-07:00        2c47e2c0-3a76-4dc1-bfef-21392b65871b    (service ) was unable to place a task because no container instance met all of its requirements. The closest matching (container-instance 25785de8f80041e0afd7b0adfda5f2fa) is already using a port required by your task. For more information, see the Troubleshooting section of the Amazon ECS Developer Guide.
EVENTS  2021-04-21T05:29:11.592000-07:00        4279fb7c-9c36-477b-acb3-173edb8e2c31    (service ) has reached a steady state.

I'm guessing it can't create another EC2 instance because I've set the number of instances to 1 on creation of my cluster. But I tried with 2 instances and it seems overkill to have two instances up and running all the time. How can I achieve this?

**Tags:** docker, amazon-web-services, amazon-ecs, aws-ecr


---

## 1 answers

### Answer by username_1 on 2021-04-21. Score: 2

AWS container service team member here. IF you are still early on in your journey to automate this via a CLI I would suggest you consider moving past the `ecs-cli`. The follow-on version of this CLI is called [AWS Copilot](https://aws.github.io/copilot-cli/) and has more sophistication to implement those workflows. Note that Copilot dropped support for `docker compose` because we have implemented a native integration with Docker and the new `docker compose cli`. You can read more [here](https://aws.amazon.com/blogs/containers/deploy-applications-on-amazon-ecs-using-docker-compose/) and [here](https://aws.amazon.com/blogs/containers/automated-software-delivery-using-docker-compose-and-amazon-ecs/).

> **Comments:**
> **username_0**: Thank you! Copilot seems like it could help me alot. Do you know a noob-friendly guide launching a docker compose project with AWS Copilot? Containers are very new for me so I could not really understand how I would use the info in the links you attached in Copilot.  
> **username_1**: Yes sorry, pointing to the root of the docs may be too overwhelming :) You may want to start with [this one from the docs](https://aws.github.io/copilot-cli/docs/getting-started/first-app-tutorial/) .... or with [this one from the blogs](https://aws.amazon.com/blogs/containers/introducing-aws-copilot/) for a more step-by-step first guided experience.  
> **username_1**: But I'd like to hear more from you if either fits your need (as someone completely new to container and of course Copilot) or if you need something different (care to elaborate more on what exactly?). Thanks!  
> **username_0**: Thank you very much! Basically I have a web-app I've made in Django. I'm running this project with Django, Gunicorn and Nginx. I've split this in two containers, One with Django files and running gunicorn and the second with Nginx. I also have a `docker-compose.yml` that just point to the images. My goal is basically to have some pipeline so that when I use `git push` some tests will run and the automatically deploy my containers. Right now I have automatic testing and pushing of images to my ECR registry. But the last step of autodeploy is where I'm stuck. Do you think Co-pilot is a good fit?  
> **username_1**: I think the answer to your question is a function of two things: 1) how much you rely on your docker compose file and 2) your view on IaC. If you consider compose an implementation detail you don't have strong opinions about and you like the idea of a simple CLI operational model then Copilot is a great fit. If, however, compose is central to your strategy and you want to use Git as your mechanism to track your infrastructure deployment then the Docker Compose / ECS integration I linked in my original post could be a better approach. Makes sense?  
> **username_0**: I think I got my project to work using the method described in the link in your initial post! I really appreciate you taking the time to help me, thank you!  
> **username_0**: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/123290/discussion-between-felix-eklof-and-username_1).  

---

