Home > database >  How do you push updated container images to AWS ECR?
How do you push updated container images to AWS ECR?

Time:10-30

So my understanding of containers and the associated terminology is tenuous at best, so if I say anything completely off please correct me.

I have a Lambda function that I am publishing as a container instance. I successfully pushed my container and ran my Lambda code, which had a bug (side note: Is there really no other way to test minor code changes rather than rebuild and push the entire container every time? I'm not using SAM, which is a decision I regret and am stuck with).

I went to fix the bug, and the absolute only thing I can find is the original commands:

docker build -T CONTAINER-NAME .

aws ecr create-repository --repository-name CONTAINER-NAME --image-scanning-configuration scanOnPush=true
docker tag CONTAINER-NAME:latest 1234.dkr.ecr.us-west-2.amazonaws.com/CONTAINER-NAME:latest
aws ecr get-login-password | docker login --username AWS --password-stdin 1234.dkr.ecr.us-west-2.amazonaws.com
docker push 1234.dkr.ecr.us-west-2.amazonaws.com/CONTAINER-NAME:latest

These worked fine the first time around but now run without error, but do not update my image. I suspect it has to do with the tags, which the documentation is very unclear about--are they just tags like the rest of AWS resources', or something more?. I've experimented with different combinations of changing tags, which generally leads to errors about a given tag or repo not existing.

CodePudding user response:

docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG

You can try with these code, create a new image with different tag. Mine is using date command to seperate tag. You specify the latest tag, and the running environment already has it, so it won't pull the new one.

  • Related