compose/relay
Sebastiaan van Stijn a0abda0782
Some checks are pending
ci / validate (lint) (push) Waiting to run
ci / validate (relay-lint) (push) Waiting to run
ci / validate (relay-test) (push) Waiting to run
ci / validate (validate-docs) (push) Waiting to run
ci / validate (validate-go-mod) (push) Waiting to run
ci / validate (validate-headers) (push) Waiting to run
ci / validate (validate-mocks) (push) Waiting to run
ci / binary (push) Waiting to run
ci / binary-finalize (push) Blocked by required conditions
ci / bin-image-test (push) Waiting to run
ci / relay-image-test (push) Waiting to run
ci / test (push) Waiting to run
ci / e2e (plugin, oldstable, graphdriver) (push) Waiting to run
ci / e2e (standalone, oldstable, graphdriver) (push) Waiting to run
ci / e2e (plugin, stable, containerd) (push) Waiting to run
ci / e2e (plugin, stable, graphdriver) (push) Waiting to run
ci / e2e (standalone, stable, containerd) (push) Waiting to run
ci / e2e (standalone, stable, graphdriver) (push) Waiting to run
ci / coverage (push) Blocked by required conditions
ci / ci-ok (push) Blocked by required conditions
ci / release (push) Blocked by required conditions
merge / bin-image-prepare (push) Waiting to run
merge / bin-image (push) Blocked by required conditions
merge / relay-image (push) Waiting to run
merge / module-image (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
zizmor / zizmor (push) Waiting to run
update to go1.26.10
These releases include 1 security fix following the security policy:

- crypto/x509: mitigation for security concerns with a specific Certificate Authority

  We're blocking trust in a small set of intermediate certificates due to specific security concerns around their operation.

  Verify will now filter out chains which contain these intermediates, preventing them from being returned to the caller.

  We highly recommend immediately upgrading to this release.

  This is CVE-2026-111943 and Go issue https://go.dev/issue/82345.

release notes: https://go.dev/doc/devel/release#go1.26.10

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-10-21 07:59:09 +02:00
..
.golangci.yml ci: lint, vet and test relay/ as its own module 2026-09-17 09:23:54 +02:00
Dockerfile update to go1.26.10 2026-10-21 07:59:09 +02:00
go.mod
main.go ci: lint, vet and test relay/ as its own module 2026-09-17 09:23:54 +02:00
main_test.go test: remove timing assumptions from TestBuildTLS and the relay streaming test 2026-10-12 11:55:20 +02:00
README.md

compose-relay

compose-relay is the network gateway Docker Compose deploys in place of a provider-managed service, so the other services of the project reach the provider's resource at the compose-native address — http://<service>:<port> — even though that resource lives outside the compose network.

Why it exists

A service can delegate its implementation to an external provider:

services:
  web:
    build: .
    depends_on:
      - database

  database:
    provider:
      type: awesomecloud

The provider's resource (a cloud database, a sandbox, a host process, ...) is not a container on the project network: web cannot resolve database, and the resource's ports are typically published somewhere on the host, at addresses and port numbers the application does not know. Until now consumers had to read injected environment variables to locate it.

When the provider declares where each endpoint actually listens, with one publish-endpoint message per port:

{ "type": "publish-endpoint", "message": "5432=localhost:49152" }

Compose deploys this relay in place of the service. web then connects to database:5432 exactly as if the service were a regular container; the relay forwards the connection to the real endpoint.

How it runs

Compose creates the relay container from the published docker/compose-relay image (override with COMPOSE_RELAY_IMAGE, e.g. for air-gapped setups or local development) with:

  • the service's canonical container name (<project>-<service>-1) and a network alias set to the service name, on the networks of every service that depends on the provider service;

  • the standard compose labels, so label-driven commands (ps, logs, stop, down) treat it as the service — plus the com.docker.compose.relay label identifying its role. Its value is a hash of the routes, letting up keep an up-to-date relay and recreate a stale one. Commands that act on a service's process (exec, cp) refuse relay containers;

  • the routes as environment:

    RELAY_ROUTES=5432=localhost:49152[,<port>=<host>:<port>...]
    

The binary listens on every declared container port and forwards each connection to its endpoint. TCP only, with half-close propagation so protocols relying on EOF work through the relay. It is intentionally minimal: a static Go binary on a scratch image, no configuration reload — Compose recreates the relay when the published endpoints change.

Building

$ docker buildx bake relay-image