- Newest
- Most votes
- Most comments
Has anyone found a solution for this? getting the dreaded "Layer already exists" when trying to push a fresh image to our repository with the same tag. Deleting the image doesn't fix it. Seems to be an issue specific to ECR, my local docker cache updates fine but it can't push new images to ECR, I get "Layer already exists" but they are clearly different and not being updated in ECR.
Its likely that the old image layers are not being re-built when you are building the image.
Prior to the docker build, try to force delete all of the depending image layers and see if it helps.
docker rmi -f <ImageID>
docker build -t <Image:Tag> . --no-cache
docker push <Image:Tag>
Also, it would help us understand the issue if you can provide more context like where and how you are building/deleting these images.
If the above steps do not work, please feel free to reach out to AWS Support for further troubleshooting.
I'm uploading using the CLI. I am deleting the image manually from the ECR web admin page. It shouldn't matter if I am trying to upload the exact same image, once I delete it it should be gone permanently, the very last thing that should happen is that AWS keeps an archived copy of our deleted image layers, especially the ones that are not public! This is undesirable on so many levels. When I try to upload the exact same image, it should need to be uploaded because no copy exists on AWS, period. It doesn't matter if I built an entirely new one, tagged it with something, or did nothing to it at all.
What is actually happening: - I delete all the images from the ECR repository page. It is empty. Nothing is shown. Blank list. - I upload the image from my remote machine using the AWS CLI - AWS CLI on remote machine instantly spits out "layer already exists" for the 20 or so layers - Old deleted image is magically back on ECR.
It is NOT uploading the same image again, it is 500MB and it would not be instant (in previous uploads it took several minutes). It is restoring it from a hidden trash folder or something, it still exists on AWS - this needs to be disabled permanently. We CANNOT have AWS storing/archiving deleted ECR images under any circumstances whatsoever. Perhaps there is an ECR setting to automatically archive instead of permanently deleting, that I don't know about?
What does ECR have to do with builds? It doesn't matter if the build is literally identical. Once it is deleted from ECR, it should be gone, period. You should be able to upload the same exact build and ECR should not even know that it is the same because when you delete something, it should be physically deleted, instead of being subjected to some out-of-contract, bug-ridden, undocumented garbage cache to optimize traffic and save a few cents (at best, and at worst to keep your code for Amazon's own archival/research purposes)
Relevant content
- asked 3 years ago
- asked 4 years ago
- AWS OFFICIALUpdated 10 months ago

Hello, how are you uploading these images to ECR? From your local machine, CodeBuild, or somewhere else? Also, how are you deleting these images? Manually via the console, through the CLI, or another method? The more details you can provide, the better.
Over half a year and still no solution for this... Does AWS support ever read these?
I had to delete the image image and create another one with the same name to do so.
Any solution for this?