1

Scenario: Created a new ECR private repo and pushed a new docker in it successfully. Then used that docker image to host the application. Now application needed some updated APIs so:

  1. made changes to the code.
  2. followed AWS commands to push the updated docker image in the same repo with different version number. Also while creating docker I removed the the local docker images from my pc and used the --no-cache tag as well.

While uploading I got Layers already exits for all layers except 1 (with size around 32 mb), it got pushed in 10 seconds. On ECR I can see the new updated version of the image with size same as the previous version but only around 32 mb layer was pushed in 5,10 seconds. What does this mean? I tried the whole process a couple of times and randomly one time it said Layer already exists for all layers expect 2. This time a layer with proper image size (around 330 mb) got pushed.

Could someone explain what is the best way to update your version on ECR with proper image pushes?

Vishal Kumar
  • 65
  • 3
  • 7
  • This did the job for me: 1. ```docker rmi $(docker images -a)``` (remove all existing images), 2. ```docker build . --no-cache``` (build layer) – iJup Jan 15 '23 at 11:06

2 Answers2

0

On Mac you can go into the Docker Application and delete the Images.

On linux (I linda hope someone can post a "real" solution) I delete all images and all containers manually because I only use Docker to upload to to AWS ECR.

first.

find where your docker images are located by running docker info, mine is overlay2 so /var/lib/docker/overlay2 is the path helpful ref

second.

I run these commands:

sudo rm -rf /var/lib/docker/overlay2/* # delete 
docker system prune -a  # delete docker containers
systemctl restart docker # restart docker to fix deleted necessary files
Daniel Olson
  • 73
  • 1
  • 3
-1

this is not a big concern because when we talk about docker image it has multiple build layers, so when you are pushing it on aws ecr it pushes multiple layers of image in ecr repository,and when you are update your changes and build this image and pushed new version of image in ecr it only pushes the updated layer of docker image, because other layers are already available in your ecr repository. I hope you understand this.