Skip to main content

Module ecr_uri

Module ecr_uri 

Source
Expand description

AWS ECR URI recognition + translation to the local fakecloud OCI v2 endpoint.

Shared between ECS and Lambda container runtimes: when a task definition or Lambda function references <account>.dkr.ecr.<region>.amazonaws.com/<repo>:<tag>, fakecloud can’t pull from AWS — there is no AWS account. Instead we translate the URI to 127.0.0.1:<server-port>/<repo>:<tag> and pull from fakecloud’s own OCI v2 registry (which is just another route on the same HTTP server). Docker treats 127.0.0.1:<port> as an insecure registry automatically on both Linux and Docker Desktop, so no daemon config is required.

Functions§

is_aws_ecr_uri
Detect whether image is an AWS private-ECR URI. Match shape: <any>.dkr.ecr.<any>.amazonaws.com/<path>[:<tag>|@sha256:<digest>]. The registry host is anchored so arbitrary-path substrings like docker.io/user/.dkr.ecr.whatever.amazonaws.com/bar don’t get misclassified.
is_digest_ref
Is image a digest-pinned reference (repo@sha256:...)? Docker’s tag subcommand cannot target a digest ref, so the runtime must skip retagging and run the container under the local URI directly.
translate_to_local
If image is an AWS private-ECR URI, return the local-registry URI that fakecloud’s OCI v2 endpoint serves the same content at. Returns None for any other reference (public ECR, Docker Hub, etc.) — those go straight to the upstream daemon.
translate_to_local_at
Like translate_to_local but lets the caller pick the host the rewritten URI should point at. Lambda’s Kubernetes backend needs this — inside a cluster, the in-cluster fakecloud Service hostname (not 127.0.0.1) is the only address Lambda Pods can reach.