Local ECR for integration tests

Run local Amazon ECR for tests with fakecloud. Full 58-operation API, real OCI v2 Distribution so docker push and docker pull actually work. Free, AGPL-3.0.

Need local ECR for integration tests? Use fakecloud.

curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash
fakecloud

Point your AWS SDK at http://localhost:4566. docker push / docker pull work against the same port because fakecloud implements the OCI v2 Distribution protocol, not just the JSON control plane.

Why fakecloud for ECR

Smoke test (5 commands)

# Start fakecloud.
fakecloud &

# Log Docker into the fake registry.
aws --endpoint-url http://localhost:4566 ecr get-login-password \
  | docker login --username AWS --password-stdin localhost:4566

# Create the repo, push an image.
aws --endpoint-url http://localhost:4566 ecr create-repository --repository-name demo
docker pull busybox:latest
docker tag busybox:latest localhost:4566/demo:latest
docker push localhost:4566/demo:latest

# Verify with the AWS SDK.
aws --endpoint-url http://localhost:4566 ecr describe-images --repository-name demo

Assert on what was pushed (first-party SDKs)

fakecloud exposes an introspection API at /_fakecloud/ecr/... so your test code can assert on pushed images without re-parsing Docker output.

import { FakeCloud } from "fakecloud";

const fc = new FakeCloud();
const { repositories } = await fc.ecr.getRepositories();
const { images } = await fc.ecr.getImages("demo");

expect(repositories).toHaveLength(1);
expect(images[0].imageTags).toContain("latest");

Same API in Python, Go, Java, PHP, and Rust. See the SDKs page for per-language examples.

Alternatives

fakecloud does both.

See also