Home > Back-end >  Docker keeps ignoring tags and always uses :latest
Docker keeps ignoring tags and always uses :latest

Time:01-13

I have a building process where I have these lines:

sudo docker stop myImage
sudo docker rm myImage
sudo docker build -t $tag ../../. --no-cache

sudo docker tag $tag 123456.dkr.ecr.us-east-2.amazonaws.com/myImage
sudo docker login -u AWS -p $(aws ecr get-login-password --region us-east-2) 123456.dkr.ecr.us-east-2.amazonaws.com
sudo docker push 123456.dkr.ecr.us-east-2.amazonaws.com/myImage

But when I try to deploy, I get this message:

Successfully built 123a123b123c
Successfully tagged myTag:latest
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
Using default tag: latest

This script worked a few days ago, can anyone see why it's malfunctioning now? BTW I want my tags to be both myTag and Latest in my AWS ECR

CodePudding user response:

You need to tag your ECR image with tag you want then push it as well.

sudo docker login -u AWS -p $(aws ecr get-login-password --region us-east-2) 123456.dkr.ecr.us-east-2.amazonaws.com
sudo docker tag $tag 123456.dkr.ecr.us-east-2.amazonaws.com/myImage:$TAG_YOU_WANT
sudo docker tag $tag 123456.dkr.ecr.us-east-2.amazonaws.com/myImage
sudo docker push 123456.dkr.ecr.us-east-2.amazonaws.com/myImage:$TAG_YOU_WANT
sudo docker push 123456.dkr.ecr.us-east-2.amazonaws.com/myImage
  • Related