Commit Graph
30 Commits
Author SHA1 Message Date
Mario Toffia fd8be9afee fix(ecr): pull rewritten ECR images from an address Docker Desktop reaches (#7752)
* fix(ecr): pull rewritten ECR images from an address Docker Desktop reaches

Docker Desktop's daemon runs in a VM and dials localhost there, where a host
port Docker chose for Floci is not bound, so pulls of rewritten ECR images timed
out. On Docker Desktop, rewrite to <account>.dkr.ecr.<region>.localhost:<port>,
which Desktop sends through its host proxy and pulls over plain HTTP.

* fix(ecr): warn when the Docker daemon's operating system cannot be read

The rewrite then falls back to localhost, which Docker Desktop cannot reach, so the later pull timeout needs this cause next to it.
2026-11-08 05:19:22 -04:00
Andre Kurait d6aed932a1 fix(ecr): paginate repository descriptions (#7711)
Preserve named lookups and bind continuation tokens to region and account.

Signed-off-by: Andre Kurait <akurait@amazon.com>
2026-11-06 20:47:00 -04:00
Andre Kurait f719d6af56 fix(ecr): validate lifecycle policy documents before mutation (#7611) 2026-11-05 13:54:02 -04:00
Priamo Germosen 931b2d26a7 feat(emr-serverless): run a job run in its application's custom image (#6975)
In the docker runner mode an application's imageConfiguration, and a
worker type's, was stored and returned, but every run started from the
release's public image. So a job whose libraries are baked into its own
image, the user guide's "Customizing an EMR Serverless image", could not
run. Now a run starts from the application's custom image:

- the Driver worker type's imageConfiguration, else the application's,
  which "EMR Serverless applies ... to all worker types". Local mode
  runs the executors in the driver's container, so an Executor image is
  not used;
- an <account>.dkr.ecr.<region>.amazonaws.com URI leads to Floci's ECR,
  as a Lambda function's or an ECS task's image does, and the
  repositoryUri Floci's ECR hands out works too;
- the image is pulled for every run, as an ECS task's is, so a tag
  pushed again is what the next run gets ("New workloads submitted after
  the update automatically will use the new image"), and the driver
  starts from the image id that pull resolved. When the pull fails, the
  image the Docker daemon has runs; without one the run is FAILED.

SparkJobRunner.Job carries the custom image beside the template, which
classic EMR's steps leave null.

The image configurations, the application's and each worker type's,
are checked as the user guide and the model describe them, in Floci's
own wording as no source gives AWS's:

- CreateApplication refuses one without imageUri, "This field is
  required when you create a new application";
- CreateApplication and UpdateApplication refuse an image whose ECR
  repository, AWS-shaped or a repositoryUri from Floci's ECR, is in
  another Region: "The Amazon ECR repository must be in the same AWS
  Region that you use to launch EMR Serverless applications";
- UpdateApplication with one that leaves imageUri out removes it: "If
  you leave this field blank in an update, Amazon EMR will remove the
  image configuration."

EcrRegistryManager.imageRegion reads the Region from either URI form.
Floci does not check imageUri against the model's pattern, which would
refuse the repository URIs its own ECR hands out, nor the image's
release or size, and reports no resolvedImageDigest; the service doc
lists these.
2026-10-30 07:23:11 -05:00
Aniket Shukla 8270cc7c41 feat(ecr): support pull time update exclusions (#6856)
* feat(ecr): support pull time update exclusions

* refactor(ecr): remove duplicate exclusion validation
2026-10-29 16:20:51 -04:00
Aniket Shukla e24bc36f64 feat(ecr): support account settings (#6855)
* feat(ecr): support account settings

* fix(ecr): validate account settings against request model
2026-10-29 07:36:05 -04:00
Matheus Oliveira 9ce1b1755e fix(ecr): delete only the named tag in BatchDeleteImage (#6597) 2026-10-29 00:06:36 -04:00
Aniket Shukla c37e0aaba9 fix(ecr): explain unavailable registry responses (#6752)
* fix(ecr): explain unavailable registry responses

* refactor(ecr): share registry errors and data-plane fixtures
2026-10-27 18:13:10 -04:00
David d10db3ce9b feat(ecr): repository creation templates (#5955)
* feat(ecr): repository creation templates

CreateRepositoryCreationTemplate, DescribeRepositoryCreationTemplates,
UpdateRepositoryCreationTemplate and DeleteRepositoryCreationTemplate store
templates per account and Region, keyed by prefix, with each field checked
against the service model. An update replaces the fields it sets, and an
empty string or list clears one. Templates are recorded, not applied, as
nothing in Floci creates repositories through replication, pull through
cache or create-on-push.

Closes #5804

* refactor(ecr): check repository creation templates against the vendored model

The four template actions join the registry settings in
ecr-request-shapes.json, so the handler checks their requests against the ECR
model's types, lengths, patterns and enums and answers in ECR's
"failed to satisfy constraint" form. The handwritten copies of those rules
go. What the model can't state stays in the service: appliedFor naming at
least one value, and policy text being a JSON object.

The model gives imageTagMutabilityExclusionFilters at least one entry, so an
update sending an empty list is now refused rather than clearing the filters.
Terraform omits the member when the filters are removed and moves to a mode
without exclusions, so an update that leaves the template in such a mode now
drops the filters. Before, they stayed, and every plan showed them again.

* fix(ecr): lock creation template writes, share one JSON object check and fold a trailing slash

Create, update and delete each read a template and then wrote it without a
lock, so two creates of one prefix could both succeed and an update racing a
delete wrote the deleted template back. They now take the registry lock the
registry settings use. The template policies and the registry policy share one
JSON object check that also refuses text after the object, such as {}{}.
ECR assumes a / after every prefix, so prod and prod/ are now one template.
The test helper imports Executable.

* fix(ecr): describe each template once when prefixes differ only by a slash

Describe removed duplicate prefixes before folding the trailing slash, so
prefixes prod and prod/ returned the template twice, and with maxResults 1 a
token followed by an empty page. It now removes duplicates by template key.
The lock tests use the shared testing ParkingStore instead of their own copy.
2026-10-26 19:36:42 -04:00
Aniket Shukla b29c8f8a60 fix(ecr): paginate image listings (#6544)
* fix(ecr): paginate image listings

* fix(ecr): fetch digests only for the selected page

* fix(test): await ECR tag release after stream reset

* refactor(ecr): remove unused image listing overload
2026-10-25 21:37:26 -04:00
Jimmy Liu Jia 671e4bfb7c fix(ecr): return per-repository scanning batch failures (#6569) 2026-10-25 21:33:27 -04:00
David 1f96bf42f1 feat(ecr): registry policy, replication and scanning configuration (#5817)
* feat(ecr): registry policy, replication and scanning configuration

PutRegistryPolicy, GetRegistryPolicy, DeleteRegistryPolicy, PutReplicationConfiguration,
DescribeRegistry, PutRegistryScanningConfiguration and GetRegistryScanningConfiguration store
the registry's own settings per account and Region and return them as written. Floci does not
replicate or scan images or evaluate the policy, as with repository policies.

- The policy must be a JSON object; a missing one is RegistryPolicyNotFoundException.
- Replication destinations, filters and rule counts are checked against the service model, and
  an empty rules list clears the configuration.
- Scanning defaults to BASIC with no rules, and CONTINUOUS_SCAN is refused with BASIC.

Closes #5803

* fix(ecr): put the registry setting writes under one lock

PutRegistryPolicy, DeleteRegistryPolicy, PutReplicationConfiguration and
PutRegistryScanningConfiguration read the registry's one settings record, change a
field and write it back. Terraform applies the three resources in parallel, so two
writers could start from the same record and the later write dropped the other's
setting. The read, change and write now happen under a lock per account and Region.

* refactor(ecr): check registry setting requests against the vendored model

The Resource Groups request walker moves to core.common as RequestConstraintCheck, so
a service can check a JSON request against botocore's constraints: member types,
required members, lengths and counts, number ranges, patterns and enums, each
answered in the service's own words. Resource Groups keeps its BadRequestException
messages.

- tools/aws/request_shapes.py gains build_constraints, which
  regen_resource_groups_shapes.py now calls; its vendored file is unchanged.
- tools/aws/regen_ecr_shapes.py vendors ecr-request-shapes.json for the seven
  registry setting actions, and aws-data-sync and aws-data-check run it.
- EcrJsonHandler checks those requests first, answering InvalidParameterException in
  ECR's form. The hand-written checks the model states are gone; a policy that is
  not a JSON object and CONTINUOUS_SCAN with BASIC stay, as the model cannot say
  them.
2026-10-20 10:03:30 -04:00
David c6551a47bc feat(ecr): PutImage and the layer API (#5784)
* feat(ecr): PutImage and the layer API

PutImage, BatchCheckLayerAvailability, GetDownloadUrlForLayer, InitiateLayerUpload,
UploadLayerPart and CompleteLayerUpload now go through the registry:2 container that
docker push already writes to, so an image written through the API is the image
docker pull and BatchGetImage return.

- PutImage writes the manifest under its tag, or under its digest. It answers
  ImageDigestDoesNotMatchException, ImageAlreadyExistsException,
  ImageTagAlreadyExistsException and LayersNotFoundException as the model lists them.
- Layer uploads map onto registry upload sessions, held in memory. Parts must follow
  each other, be at most 20 MiB, and all but the last at least 5 MiB.
- GetDownloadUrlForLayer returns the blob's address on Floci's registry endpoint.
- The immutable-tag guard moves into EcrService, so a docker push and a PutImage of
  one tag cannot both succeed.

Closes #5735

* fix(ecr): refuse mixed layer digests, keep push time on retag, expire idle uploads

CompleteLayerUpload refuses a second, different layer digest instead of
ignoring it. PutImage keeps an image's first push time when it retags it.
A layer upload idle for a day is refused even when no other upload opens,
and dropping one cancels its registry upload session.

* fix(ecr): check PutImage tags, require a manifest media type, share registry error handling

- PutImage checks imageTag against the OCI tag grammar and answers
  InvalidParameterException otherwise. The tag goes into the registry's manifest URL,
  so v1?x wrote v1 and a slash wrote into another repository.
- A manifest with no mediaType needs imageManifestMediaType, as on AWS, instead of
  Floci guessing one from the manifest's shape.
- PutImage and the layer API reach the registry through one helper, callRegistry,
  in place of five copies of the same failure handling.

* fix(ecr): answer ECR's own message for a tag outside its rule

PutImage refuses a tag outside ECR's rule, [a-zA-Z0-9-_.]+ up to 300 characters,
with ECR's message. A tag ECR takes but the backing registry cannot hold, one
starting with '.' or '-' or longer than 128 characters, is refused with a message
naming that limit, which docs/services/ecr.md now notes.
2026-10-20 07:29:43 -04:00
Alessandro Lattao 553411bc70 fix(ecr): pull rewritten ECS and Lambda images from localhost (#5882)
Floci rewrites an AWS-shaped ECR image of an ECS task or an image-backed
Lambda to its loopback registry and hands that address to the Docker
daemon, as <account>.dkr.ecr.<region>.localhost:<port>/<repo> in the
hostname style. A daemon with the containerd image store, the default
from Docker Engine 29, cannot pull from it. Measured on Docker 29.9.1:
against a plain HTTP registry:2, localhost:<port> and 127.0.0.1:<port>
are reached over HTTP, while any *.localhost name is tried over HTTPS
only ("server gave HTTP response to HTTPS client"), the 127.0.0.0/8
insecure CIDR notwithstanding. With Floci's TLS on, the same names reach
Floci's TLS port and fail on its certificate instead (unknown authority,
and *.localhost names are not in it). The containers never start: ECS
reports TaskFailedToStart.

So the rewrite now always gives localhost:<port>/<account>/<region>/<repo>,
path style, in either URI style and with or without TLS: the address
every daemon, classic or containerd store, pulls from over plain HTTP.
The data plane claims path-style requests on a loopback host (localhost,
127.0.0.0/8, ::1) in the hostname style too, so those pulls still go
through it and its repository name mapping. Nothing else changes: the
advertised repositoryUri, the login endpoint and pushes keep their style.
2026-10-17 14:11:08 -04:00
Mario Toffia c1cd5af2bd fix(ecr): advertise the registry at the published address (#4863)
ECR built repositoryUri, the GetAuthorizationToken proxyEndpoint and
the Lambda and ECS image rewrites from floci.port, the port Floci
listens on inside its own container. The Docker daemon performs login,
push and pull, and reaches Floci through the host port that container
publishes. When Floci ran as docker run -p 54321:4566, every advertised
address named port 4566 on the host, where nothing answers, so docker
login, CDK container asset publishing and ECS or Lambda image pulls
failed.

EcrRegistryManager now has advertisedPort(): the host port Floci's
container publishes for floci.port, read through the existing
CurrentContainerNetworkResolver.resolvePublishedPort as RDS does for
its proxy endpoint, or floci.port when Floci is not in a container or
the port is not published. repositoryUri (hostname and path style,
plain and TLS URI mode), proxyEndpoint and rewriteImageUri all use it.

The EKS registry mirror keys must match the URIs pods name, so they
use the same advertised port. The mirror endpoint stays Floci's
in-network address on floci.port.

The resolver now caches every published-port answer, "not published"
and a failed inspect included, as it already caches the network: a
running container's port bindings cannot change, and an inspect that
fails fails the same way next time. ECR requests therefore do not
inspect the container each time.
2026-10-08 20:11:30 -04:00
Mario Toffia 8b1ece9c24 fix(ecr): retry occupied registry ports (#4857)
* fix(ecr): retry occupied registry ports

The backing registry reserved one port from the configured range and gave
up when Docker refused to publish it, although the next port was free. The
allocator's probe races `docker run`, and from inside a container it cannot
see a host process holding the port, so a refusal is expected and not fatal.

A start Docker refuses as a host-port collision now moves on to the next
port in the range; any other failure still fails at once. Refused ports stay
reserved until the start finishes so each is tried once, then are released.
When the range runs out the error names the refused ports. EC2's collision
check moves to PortAllocator so both callers share it.

Closes floci-io/floci#4856

* chore(ecr): keep the port retry tests independent of host ports

The unit tests now use an allocator that skips the host probe, so a busy
6100 or 6101 on the machine cannot change their outcome. The integration
test picks its port pair with the Docker-aware allocator, so a container
already publishing a port is skipped as well, and drops its logger.

* docs(ecr): say other registry start errors still fail at once

The paragraph said startup fails only when the range is full, but a daemon
or image failure still fails without trying another port. The exhaustion
tests now also allocate the last refused port, so releasing only some of
them fails.

* refactor(ec2,ecr): share the port retry loop in PortAllocator

Review asked for the allocate, start and retry loop itself to live in one
place, not just the collision check. PortAllocator.allocateAndStart takes
the start as a callback, moves past ports Docker refuses as in use, and
releases the refused ports when it returns. ECR and EC2 both call it.

EC2 used to mark a refused SSH port reserved for the life of the process.
It now releases it after the launch, as ECR does, so a port whose holder
goes away is usable again.

With the loop moved, a launch cancelled between attempts can now reach
the worker's failure path. When Docker is also gone that path marked the
instance running without a container, so it now goes through markRunning
and leaves a cancelled instance terminated.

* test: share one host-blind PortAllocator across the port tests

PortAllocatorTest, EcrRegistryManagerTest and the ECR port-conflict
integration test each built their own allocator that skips the host
probe. HostBlindPortAllocator replaces the three copies.
2026-10-08 15:31:03 -04:00
Vũ Thế Huy 543f01618f fix(ecr): support image scanning configuration updates (#4928)
* fix(ecr): support image scanning configuration updates

* fix(ecr): validate scanning configuration booleans

* fix(ecr): accept null scan-on-push values

* docs(ecr): list the image scanning configuration actions

Add PutImageScanningConfiguration and BatchGetRepositoryScanningConfiguration
to the Supported Actions table. The table is not generated, so the docs check
does not catch a missing row.
2026-10-03 00:01:40 -04:00
XuJian b658c5f020 feat(ecr): update and validate pull-through cache rules (#4342) 2026-09-24 15:38:19 -04:00
XuJian 1952ba4052 feat(ecr): manage pull through cache rules (#4304)
Signed-off-by: XuJian <265865031+xujiantop-crypto@users.noreply.github.com>
2026-09-24 08:36:06 -04:00
XuJian 22c56157ee feat(ecr): advertise TLS registry URIs on opt-in (#4252) 2026-09-23 16:46:10 -04:00
Simone Primarosa 7777a97de9 fix(ecr): serve the registry data plane over TLS (#4040)
- Update ECR host routing regex to support <account>.dkr.ecr.<region>.localhost.floci.io
- Populate regional wildcard SANs (*.dkr.ecr.<region>.localhost.floci.io) for all advertised AWS regions
- Add unit tests for hostname matching, malformed host rejection, immutable tag mutability over TLS, and certificate SAN enumeration
- Add Docker integration test verifying end-to-end TLS image push/pull with root CA verification and plain HTTP regression
- Update ECR and TLS user documentation
2026-09-20 22:11:46 -04:00
Simone Primarosa 95079965a8 fix(ecr): enforce immutable image tags (#3009)
Route Docker Distribution traffic through Floci so repository mutability applies to manifest writes. Keep legacy registry storage reachable while moving public ECR endpoints to the guarded listener.
2026-09-14 12:07:40 -04:00
Kurt McAlpine 23728e0b75 feat(ecr): prefer locally present images over the loopback registry rewrite (#3022)
* feat(ecr): prefer locally present images over the loopback registry rewrite

EcrRegistryManager.rewriteImageUri rewrote every AWS-shaped
<account>.dkr.ecr.<region>.amazonaws.com/<repo>:<tag> URI to Floci's
loopback registry unconditionally, so a container image Lambda function
(or ECS task) whose image was built locally and tagged with its real ECR
URI could never run: the launcher started the registry:2 sidecar and
tried to pull from it, failing with "failed to resolve reference ..."
(Lambda.InitError) even though the daemon already held the image.

The rewrite now first asks the Docker daemon whether the image exists
under the URI as given; if it does, the URI is used unchanged and the
registry container is not started. Images the daemon does not have keep
the existing rewrite-and-pull path, so CDK DockerImageFunction flows are
unaffected. floci.services.ecr.prefer-local-images
(FLOCI_SERVICES_ECR_PREFER_LOCAL_IMAGES, default true) restores the old
behaviour when set to false.

Verified with a provided.al2023 Go image tagged
000000000000.dkr.ecr.ap-southeast-2.amazonaws.com/e2e/hello-image:local:
Invoke fails on 2.0.1 and succeeds with this change, both with Floci as
a host process and inside a container sharing the host's docker.sock; an
image absent from the daemon still takes the rewrite path.

* fix(ecr): inspect the image reference ContainerBuilder launches when preferring local images

With floci.docker.image-registry-base set, rewriteImageUri inspected the bare
AWS-shaped URI while ContainerBuilder later prefixed it, so a locally present
image was reported as found and then missed at launch. Resolve the image
through ContainerBuilder before asking the daemon so both paths agree.
2026-09-04 10:59:51 -04:00
Simone Primarosa 732e009207 fix(ecr): clean up registry storage (#2982)
Remove every manifest for a forced repository deletion and reclaim the shared registry volume only when storage pruning is configured.
2026-09-03 08:14:56 -04:00
Hector Ventura 7586a01cf9 fix(eks): let pods pull images pushed to the Floci ECR registry (#1762)
k3s containerd could not reach the emulated ECR registry: repository
URIs embed localhost plus the host-published port, which resolves to the
k3s container itself, and containerd requires a registries.yaml entry
before it will speak plain HTTP to a registry.

New clusters now get a generated /etc/rancher/k3s/registries.yaml,
injected through the Docker API before the container starts, that
mirrors every repository hostname the emulator can mint (the default
account across the region catalog, plus the path-style form) to the
registry container's in-network endpoint. Public registries are never
matched, and any failure skips the mirror without aborting cluster
creation. Opt out with FLOCI_SERVICES_EKS_ECR_REGISTRY_MIRROR=false.

Closes #1761
2026-07-06 21:36:14 -05:00
Hector Ventura 9e35046647 Docs/enviroment instead yml (#764)
* docs: moving all config to env instead of yml
* docs: sync with main and new features
* docs: reverting docker-compose.yml
2026-05-10 11:53:31 -05:00
Kenshin Okinaka 88f40a839b docs: update Docker image references to floci/floci (#595)
* docs: update Docker image references to floci/floci
* docs: keep README Docker Hub badges pointing to hectorvent/floci

The hectorvent/floci image has accumulated pull and size metrics; switch
the badges to floci/floci once the new image has comparable numbers.
2026-04-25 09:29:39 -05:00
Hector Ventura e9f6417713 fix(ecr): fixing port and network issues on ecr (#483)
* fix(ecr): fixing port and network issues on ecr
* fix: issue on merge with main
* fix(ecr): connect containers to network after start only when port bindings exist
2026-04-16 21:34:26 -05:00
Hector Ventura 788ccc8404 fix(ecr,s3): fix CDK compatibility and resolve macOS ECR port conflict (#354)
* fix(ecr,s3): fix CDK compatibility and resolve macOS ECR port conflict
* fix: remove go.mod
2026-04-11 15:32:06 -05:00
Conor Heine a0ed51e9d1 feat: ecr (#337) 2026-04-11 09:59:05 -05:00