28.7 Cross-Account and Cross-Region Image Replication

Right, so you’ve built a container image. It’s a beautiful, perfect snowflake of an artifact, and you’ve dutifully shoved it into an ECR repository in your dev account. Now the fun begins: your prod account in a completely different region needs it. You could do the whole docker pull, retag, docker push dance, but that’s manual, error-prone, and frankly, a little sad. We’re engineers, not pack mules. Let’s automate this properly with cross-account and cross-region replication.

28.6 Lifecycle Policies: Automatically Expiring Old Image Tags

Right, so you’ve got an ECR repository filling up with old container images. It happens to the best of us. You push v1.2.3, then v1.2.4, and before you know it, you’ve got three gigabytes of image layers from builds you haven’t thought about in six months clogging up your AWS bill. Manually deleting these is a tedious, error-prone nightmare. This is where lifecycle policies come in—they’re the automated janitor for your container attic.

28.5 ECR Enhanced Scanning: Inspector Integration for CVE Detection

Right, so you’ve got your images in ECR. Good for you. But let’s be honest, you’re not just pushing “Hello World” apps in there, are you? You’re running actual software, which means you’re inheriting other people’s problems, usually in the form of Common Vulnerabilities and Exposures (CVEs). Manually scanning for these is a chore fit for an intern, not you. This is where ECR’s Enhanced Scanning feature comes in, and it’s one of the few AWS services that feels like it actually does the work for you without a constant, nagging guilt trip about configuration.

28.4 Image Tag Immutability: Preventing Tag Overwriting

Right, so you’ve built your container image, pushed it to ECR, and deployed it to production. Life is good. Then, a week later, you run a simple docker push after a bug fix and suddenly your staging environment, which was humming along nicely, starts behaving like it’s possessed. Why? Because you just overwrote the :staging tag with a new image digest. The tag moved, but your running containers didn’t get the memo. They’re still running the old digest, blissfully unaware that their supposed identity has been stolen. This is the chaos that image tag immutability is designed to prevent.

28.3 ECR Public Gallery: Sharing Images Without Authentication

Right, so you’ve built a container image. It’s a beautiful, perfect little snowflake of an application, and you want to share it with the world. Or maybe just your friend Dave. You could push it to Docker Hub, but then you’re managing yet another account, another set of credentials, and you’re subject to their rate limits. Or, you could use the registry you’re already using for your private stuff—Amazon ECR—but make it public. Enter the ECR Public Gallery, AWS’s answer to the public container registry space.

28.2 Pushing and Pulling Images with Docker CLI and aws ecr get-login-password

Right, so you’ve got an image built and you’re ready to stash it somewhere AWS can actually use it. That somewhere is ECR, and getting your image in and out is our only job right now. It’s a simple process, but AWS, in its infinite wisdom, has made the authentication part just convoluted enough to be a consistent pain point. We’re going to conquer it. Not just the “how,” but the “why the hell does it work like this?”

28.1 ECR Private Repositories: Creating and Authenticating

Alright, let’s talk about ECR private repositories. Think of them as your own private, highly secure art gallery for your container images. Unlike Docker Hub, where you might leave your images on a public park bench for anyone to poke at, an ECR private repo is a vault. You control exactly who and what gets in. And because it’s AWS, it’s deeply integrated with all the other toys in their sandbox (IAM, CloudTrail, etc.), which is both its greatest strength and occasionally its most annoying source of complexity.

— joke —

...