Reputation: 185
So, I was new to ECR/ECR I already pushed an image to my repo with latest tag. But what happens when I push another image with latest tag to the same repo? Will the old one tag changes because I want them to be there. Also, I can't change the tag every time as I wrote a pipeline as below. Do we have to redeploy the image to ECS? Or is it done automatically when we push new image to ECR ?
stage('docker image') {
steps {
sh ''' #!/bin/bash
set -x
cd $WORKDIR/search-adapter-service
if [[ -f "/home/jenkins/.m2/settings.xml" ]]
then
mv /home/jenkins/.m2/settings.xml /home/jenkins/.m2/settings.xml_back
fi
$WORKDIR/apache-maven-3.6.3/bin/mvn clean install
'''
dir("$WORKDIR/search-adapter-service"){
script{
sh(script: "sudo docker build -t ${DOCKER_REGISTRY_REPO}:latest .")
sh(script: "sudo docker push ${DOCKER_REGISTRY_REPO}:latest")
1.I am expecting to it change the tag automatically for the old image. 2. Will it automatically also deploy to ECS? once we push? Or do we need to do it manually? If it can be automated. How do we achieve that?
Upvotes: 9
Views: 6541
Reputation: 200850
The old image with the latest
tag will sill be in ECR, it will just have the latest
tag removed from it. If it had other tags it would still be accessible by those other tags. If it didn't have other tags, you would have to use the docker image ID (digest) to address it. All this is visible in the ECR web console.
ECS will not automatically deploy when you push a new image to ECR. You will need to trigger an ECS deployment via the command:
aws ecs update-service --cluster <cluster> --service <service> --force-new-deployment
Upvotes: 10