Commit Graph
17 Commits
Author SHA1 Message Date
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