If your task is running under a service you can force a new deployment. This forces the task definition to be re-evaluated and the new container image to be pulled.
aws ecs update-service --cluster <cluster name> --service <service name> --force-new-deployment
Answer from Dima on Stack OverflowHow do I deploy updated Docker images to Amazon ECS tasks? - Stack Overflow
ECS newbie: Simplest way to deploy an existing app to ECS?
Publish and deploy docker image to AWS ECS
amazon web services - Deploy Docker Image on AWS ECS - Stack Overflow
Videos
If your task is running under a service you can force a new deployment. This forces the task definition to be re-evaluated and the new container image to be pulled.
aws ecs update-service --cluster <cluster name> --service <service name> --force-new-deployment
Every time you start a task (either through the StartTask and RunTask API calls or that is started automatically as part of a Service), the ECS Agent will perform a docker pull of the image you specify in your task definition. If you use the same image name (including tag) each time you push to your registry, you should be able to have the new image run by running a new task. Note that if Docker cannot reach the registry for any reason (e.g., network issues or authentication issues), the ECS Agent will attempt to use a cached image; if you want to avoid cached images from being used when you update your image, you'll want to push a different tag to your registry each time and update your task definition correspondingly before running the new task.
Update: This behavior can now be tuned through the ECS_IMAGE_PULL_BEHAVIOR environment variable set on the ECS agent. See the documentation for details. As of the time of writing, the following settings are supported:
The behavior used to customize the pull image process for your container instances. The following describes the optional behaviors:
If
defaultis specified, the image is pulled remotely. If the image pull fails, then the container uses the cached image on the instance.If
alwaysis specified, the image is always pulled remotely. If the image pull fails, then the task fails. This option ensures that the latest version of the image is always pulled. Any cached images are ignored and are subject to the automated image cleanup process.If
onceis specified, the image is pulled remotely only if it has not been pulled by a previous task on the same container instance or if the cached image was removed by the automated image cleanup process. Otherwise, the cached image on the instance is used. This ensures that no unnecessary image pulls are attempted.If
prefer-cachedis specified, the image is pulled remotely if there is no cached image. Otherwise, the cached image on the instance is used. Automated image cleanup is disabled for the container to ensure that the cached image is not removed.
I have forked an open source project and I would like to deploy it to ECS.
It has a docker-compose.yml .
Theoretically one can use such a file with ECS. But I have already run into three problems and I wonder if this is not really a reliable strategy. It seems to me that the ECS back-end for docker is poorly implemented.
I'll get to the main problem and you can skip the rambling after if you aren't interested in it.
The main problem is that I changed the docker-compose.yml to use ECR (because docker basically required me to). That works locally, but remotely I get:
$ docker --context default -D -l debug compose up 2>&1 | tee /tmp/logs_local.txt FrontendTCP5173Listener CreateComplete FrontendService CreateInProgress FrontendService CreateInProgress Resource creation Initiated level=debug msg="Delete CloudFormation stack" docsgpt FrontendService EssentialContainerExited: Essential container in task exited docsgpt DeleteInProgress User Initiated FrontendService CreateFailed Resource creation cancelled FrontendService DeleteInProgress
I don't know how to get more information about the failure:
$ docker compose logs ResourceNotFoundException: The specified log group does not exist.
How do I figure out why the FrontendService exited?
===
That's the main problem. Here is the rambling about other problems that got me to this point which you can read or not, per your preference.
Starting from the original YML, it seems to require me to supply an image name in the iml instead of being able to just build into the cloud as in the original yml.
$ docker compose up WARNING [services.build](https://services.build): unsupported attribute service frontend doesn't define a Docker image to run: incompatible attribute
So I already need to change the docker-compose, which is at odds with Amazon's message that you can just use your docker-compose as-is.
This brings me to the next issue: even the slightest typo in the docker-compose.yml causes a silent failure. Which is horrible UX for a developer CLI. I can work around it, but it degrades my confidence in the tooling and makes me think that it might not be properly supported and implemented.
Anyhow, I want to add an image: line to my file.
It's unclear whether the images in my "default" local context are available in the "ecs" context because `docker compose images` says:
$ Command "compose images" not available in current context (awsdocgen). "not implemented"
Lots of commands are not implemented in this context. Another thing lowering my confidence level.
So I add the image: line to my file based on my local image ID: `image: 2d36783e9f21`
Now I get:
INFO trying next host error="pull access denied, repository does not exist or may require authorization: server message: insufficient\_scope: authorization failed" [host=registry-1.docker.io](https://host=registry-1.docker.io) pull access denied, repository does not exist or may require authorization: server message: insufficient\_scope: authorization failed
I think it's trying to look for my image on docker hub, whereas I want it to use my local one.
So my second question is: Can I do this without using ECR and putting ECR image names in my docker-compose.yml?
Hi! I have an azure repo of a simple website that has a Dockerfile which I'm building with my Azure Pipelines
I want to publish that project into my aws ecs, and I was thinking of doing it with the azure pipelines releases, but since my account is free, it seems it doesn't have this option.
trigger:
branches:
include:
- dev
- prod
pool: my-laptop
variables:
- name: imageName
value: prueba
- name: environment_name
${{ if eq(variables['Build.SourceBranchName'], 'dev') }}:
value: dev
${{ if eq(variables['Build.SourceBranchName'], 'prod') }}:
value: prod
stages:
- stage: Build
jobs:
- job: Build
displayName: Build Job
steps:
- task: Docker@2
displayName: Build an image
inputs:
repository: $(imageName)
command: build
Dockerfile: DockerfileThis is my pipeline for now.
Thank you!
After playing around it for a while, I fixed the issue.
As the docker container is running on port 3000, I needed to add 3000 to the security group and hit the public ip with port 3000.
You might be running into some permission issue inside the container where it tries to create the index.html but fails due to insufficient permissions, you might try doing a CHMOD 755 over the directory , the other way to debug would be to run the docker locally and see if you end up with same issue, then you can add the CHMOD (if thats the issue) to your dockerfile to build the new image. Hope this gives you some direction