1712 Commits
Author SHA1 Message Date
Nicolas De Loof 5ec38bbd5c test: image volume from an already-local image
Regression test for #14005, pulled-image scenario: with the source image
of a type=image volume already present in the local store, compose used
to rewrite the mount source to a digest the daemon can't resolve as a
mount source under the containerd image store (No such image).
TestImageVolume only exercises this path when a previous test happens to
have left the image locally; pre-pulling makes it deterministic. Also
asserts a second unchanged up doesn't recreate the service.

The test fails on main under the containerd image store and passes with
the fix from #14011.

Signed-off-by: Nicolas De Loof <[email protected]>
2026-08-13 12:03:29 +02:00
Nicolas De Loof 7ff6748564 test: local multi-platform image must satisfy the missing pull policy
Regression test for #14007: with the containerd image store, a local
multi-platform image holding the requested non-native variant must be
used as-is by the default missing pull policy — compose used to inspect
the image without a platform, compare the host variant's platform fields
to the requested one, conclude the image is missing and try to pull the
(unpublished) tag.

The test fails on main and passes with #14011, whose platform check
resolves the requested platform against the locally available manifests.

Signed-off-by: Nicolas De Loof <[email protected]>
2026-08-13 12:03:29 +02:00
Nicolas De Loof b32c5b9a94 docs+test: disambiguate content digests from distribution digests
Compose manipulates two digest kinds that must never be conflated:
the platform-specific content digest (localContentDigest) is ONLY an
identity to compare a running container with a fresh build/pull, while
pinning image references in a reproducible compose model (publish /
config --resolve-image-digests) must keep the registry descriptor
digest — the multi-platform index — through ImageDigestResolver, or
the published file would be bound to the platform of whoever resolved
it. Document the distinction on both producers and lock it with a test
that fails if the resolver ever goes through a local image inspect.

Signed-off-by: Nicolas De Loof <[email protected]>
2026-08-13 12:03:29 +02:00
Nicolas De Loof a2e7fe6590 test: cover image-identity corner cases end to end
- dry-run up with a missing image must not hit the real daemon
- create twice with a non-native DOCKER_DEFAULT_PLATFORM is idempotent
- two services sharing an image with mixed platform pinning get their
  own platform's digest label, idempotently, whatever pull ordering
- explicit pull refreshes ahead of a daily refresh window

Signed-off-by: Nicolas De Loof <[email protected]>
2026-08-13 12:03:29 +02:00
Nicolas De Loof 64cbcb2276 fix: address image-identity review findings
- pullRequiredImages resolves each distinct pulled image once, after
  all pulls completed, for the host default platform — the exact way
  getLocalImagesDigests resolves already-local images. Resolving from
  each pull's goroutine, for the pulled platform, let the recorded
  digest depend on pull completion order when several services pull
  the same tag for different platforms (last-writer-wins), and made
  the first up after a pull recreate containers. Platform-pinned
  services keep getting their own platform's digest from
  serviceImageDigest. In dry-run nothing was actually pulled, so the
  local inspect is skipped — it reached the real daemon through a
  DryRunClient dispatch that no longer matched and failed with 'No
  such image'.
- explicit 'compose pull' treats daily/weekly/every_N windows as due:
  it is the only way to force a refresh ahead of the window.
- 'compose pull' no longer silently skips services declaring both
  provider: and image:.
- pre_start hook images go through the same mustPull interpreter on the
  up path as on the pull path, so refresh windows apply consistently.
- matchLocalManifest falls back to the inspect's flat platform fields
  when the lone available manifest carries no ImageData (locally built
  images), instead of reporting the platform unsatisfied and pulling a
  possibly local-only image.
- scale resolves DOCKER_DEFAULT_PLATFORM without validating
  build.platforms: a conflict on a service that isn't being built must
  not abort the command. run needs nothing: createOptions.Apply
  resolves and validates platforms on its path already.
- resolveImageVolumes documents the accepted one-time-recreate and
  retag-race tradeoffs.

Signed-off-by: Nicolas De Loof <[email protected]>
2026-08-13 12:03:29 +02:00
Guillaume Lours d5e275dfb8 fix(pull): interpret pull_policy like up does
compose pull switched on the raw pull_policy string: daily/weekly/every_N
never matched a case and fell through to an unconditional re-pull, and
the hook-image loop was a second interpreter that ignored the refresh
window entirely. Delegate the decision to the exact interpreter the up
path uses (mustPull), with hook images routed through the same decision
(build mapped to missing — a hook image can't be built as a fallback).

Two deliberate differences with up are kept and documented in
shouldPullImage: a service without an explicit pull_policy is always
refreshed (skipping it would turn an explicit compose pull into a no-op
once images exist), and a present latest tag is still refreshed under
missing/if_not_present — the tag is expected to move, and triggering the
pull lets the daemon negotiate with the registry, a manifest check with
no download when the local image is already current.

User-visible change (changelog): compose pull now honors
daily/weekly/every_N refresh windows instead of always re-pulling.

Signed-off-by: Guillaume Lours <[email protected]>
2026-08-13 12:03:29 +02:00
Guillaume Lours a9d054fb17 fix(build): canonical content-digest producer, single image-label writer
Image identities recorded for staleness detection were produced by
several independent paths yielding different digest kinds for the same
image: the platform check compared flat inspect fields while the digest
picked a manifest with the host matcher (never the service's pinned
platform), a wrong-platform summary just discarded still leaked its
digest into the label, bake substituted digests host-side in batch, and
the classic builder recorded the raw build-stream ID as-is. Any of those
mismatches makes the next up see a phantom image change and recreate
containers.

Converge every producer on one selection (matchLocalManifest /
localContentDigest): the shared parallel inspect feeds both the digest
and the platform check, platform-pinned services resolve THEIR platform's
manifest in-process (no extra API call), and both builders route through
canonicalBuiltDigest. Registry-only builds (push-only, multi-platform
without load) keep the builder-reported digest — volatile but honest, an
actual rebuild is still detected, where a stable placeholder would hide
real image changes. ensureImagesExists' final loop becomes the label's
single writer so the pinned resolution can't be overwritten, superseded
only by pull/build results already platform-resolved by their producers —
and when a pull or build refreshed the shared entry mid-run (a digest
resolved for whichever service triggered it), a service pinned on another
platform re-resolves its own with one extra inspect, in that case only.

With every producer converged, TestUpIdempotentContainerdStore is
un-skipped here.

Signed-off-by: Guillaume Lours <[email protected]>
2026-08-13 12:03:29 +02:00
Max MalmandClaude Fable 5 599e12216d Use content digest for pulled service images
pullServiceImage returned the pulled image's raw inspect ID, while
getImageSummaries resolves already-local images through contentDigest
(the platform image-manifest digest). Both values feed the
com.docker.compose.image label that mustRecreate compares to detect
image changes, so the two paths disagreeing made the first 'up' after
the pulling 'up' see a phantom image change and recreate every
container once, with no change anywhere. Under the containerd image
store a tag@digest reference triggers this: the raw inspect ID is the
index digest, while contentDigest picks the platform manifest digest.

Resolve the pulled image through the same manifests-aware inspect and
contentDigest call getImageSummaries uses, so both sides of the
staleness comparison speak the same scheme.

Verified against a fresh docker:dind (29.7.0, containerd store) with a
tag@digest service: unpatched v5.4.0 recreates the container on the
second 'up'; with this fix the container survives repeated 'up' runs.
Existing behavior is preserved for engines without manifest support
(contentDigest falls back to the plain ID).

(Squashed with the follow-up lint cleanup from the same PR.)

Co-Authored-By: Claude Fable 5 <[email protected]>
Signed-off-by: Max Malm <[email protected]>
Signed-off-by: Guillaume Lours <[email protected]>
2026-08-13 12:03:29 +02:00
Guillaume Lours d98c41ba07 ci(e2e): run e2e against the containerd image store
The e2e suite only ran on graphdriver daemons, where the different kinds
of image digests coincide — the blind spot that let #13636, #13998 and
#14005 through. Add one matrix entry enabling the containerd image store,
plus TestUpIdempotentContainerdStore: two consecutive `up` runs with no
change must not recreate any container. The test is red on this
configuration (the com.docker.compose.image label is written from the
index digest on the pulling run, then compared against the per-platform
manifest digest on the next run) and skipped until the next commit
resolves the pull-path digest.

Signed-off-by: Guillaume Lours <[email protected]>
2026-08-13 12:03:29 +02:00
Ricardo Branco 1615bf352f fix(build): resolve image volumes to a mountable name, not a manifest digest
With the containerd image store, ImageSummary.ID holds the digest of the
platform-specific manifest so ServiceHash stays stable across attested
rebuilds (see contentDigest). resolveImageVolumes reused that same value
as the `type: image` mount Source, but the daemon only resolves a mount
Source by name/tag or top-level image ID, not by manifest digest — so
`compose up` failed with "No such image" whenever the volume's source
image was already present locally (always for a built image; on a
second run for a pulled one).

Keep Source as the resolved image name, and track the digest separately
via a new com.docker.compose.image-volume-digest label so mustRecreate
can still detect a rebuilt/updated source image independently of Source.

Fixes #14005

Signed-off-by: Ricardo Branco <[email protected]>
Signed-off-by: Guillaume Lours <[email protected]>
2026-08-13 12:03:29 +02:00
Branislav Osif fc860cbd1f fix: ignore one-off container events in up monitor
`up --abort-on-container-exit` tore down the project when a one-off
container created by `docker compose run` exited. The container list
built in monitor.Start already excludes one-off containers via
oneOffFilter(false), but the event subscription did not, and the only
guard on incoming events is the service label, which a one-off
container inherits from the service it was run from.

Regression since v2.39.0 (last unaffected release is v2.38.2), and a
recurrence of docker/compose-cli#1955, fixed there by
docker/compose-cli#1987.

Signed-off-by: Branislav Osif <[email protected]>
2026-08-12 16:02:25 +02:00
Endika Iglesias 832673c8e4 test(watch): cover the permission branches as root
CI runs the tests as root, where the unreadable-directory test is always
skipped. Extract the WalkDir callbacks and inject the watch registration
so a synthetic permission error can drive those branches instead.

Signed-off-by: Endika Iglesias <[email protected]>
2026-08-11 14:10:40 +02:00
Endika Iglesias fb543842d8 fix(watch): skip unreadable directories instead of failing the watch
Signed-off-by: Endika Iglesias <[email protected]>
2026-08-11 14:10:40 +02:00
Guillaume Lours 7bc2630b65 fix(config): resolve service environment when computing --hash
Containers are created from a project whose service environment is
resolved (env_file merged into environment), but since v2.22.0 `config
--hash` skipped that resolution, so hashes diverged from the
com.docker.compose.config-hash label for services using env_file.

Resolve the environment of the hashed services only, so a broken
env_file or platforms on an unrelated service still doesn't prevent
hashing, and honor --no-env-resolution as an escape hatch.

Fixes #14001

Signed-off-by: Guillaume Lours <[email protected]>
2026-08-11 08:37:13 +02:00
Guillaume Lours 5573bd2601 fix(watch): stop pruning every dangling image of the project
pruneDanglingImagesOnRebuild probed the name-keyed built-images map with
an image ID, so the spare-check never matched and every dangling image
carrying the project label was removed on each rebuild with --prune —
not just the superseded ones. Match dangling IDs against the map's
values (the freshly built image IDs) instead.

Signed-off-by: Guillaume Lours <[email protected]>
2026-08-11 08:05:14 +02:00
Ricardo Branco 668d81d4ec test: Set stop_signal to SIGTERM in nginx-based services
The official nginx images set STOPSIGNAL to SIGQUIT which dumps core.
Set it to SIGTERM to avoid dumping core on e2e tests when containers
running "sleep infinity" are stopped.

Signed-off-by: Ricardo Branco <[email protected]>
2026-08-10 12:42:02 +02:00
Eric Wyles d95ff5b3d5 Reuse bridge image version in e2e tests
Signed-off-by: Eric Wyles <[email protected]>
2026-08-06 16:00:08 +02:00
Eric WylesandGuillaume Lours 1b76c732f2 Update pkg/bridge/convert.go
Co-authored-by: Guillaume Lours <[email protected]>
Signed-off-by: Eric Wyles <[email protected]>
2026-08-06 16:00:08 +02:00
Eric Wyles c25474844c fix(bridge): skip pulling default image references for build-only services
Signed-off-by: Eric Wyles <[email protected]>
2026-08-06 16:00:08 +02:00
Guillaume Lours cda9f2044f fix(oci): fetch artifact layers from blobs endpoint, not via Resolve
Pulling an oci:// resource resolved each layer digest through the
registry manifests endpoint, which answers 500 when the digest points
to a non-manifest blob. containerd v2.3.0+ (pulled in by buildx v0.36
and buildkit v0.32) no longer falls back to the blobs endpoint unless
manifests returned 404, so publish/pull of compose artifacts broke.
Fetch layers directly with the descriptors already listed in the
manifest instead of resolving them again.

Signed-off-by: Guillaume Lours <[email protected]>
2026-08-03 14:56:34 +02:00
Guillaume Lours d8370536f0 fix: tolerate missing env file on scale, watch and shell completion
Follow-up to #13603: scale, watch and shell completion loaded the
project without any tolerance option, so a missing env_file on a
service not involved in the operation aborted the command, while
up/exec/ps already tolerate this since #13156 and #13603.

Mirror the WithServices pattern: load with WithoutEnvironmentResolution
and resolve the environment once the project has been reduced to the
selected services, so targeted services still get their env_file
validated. Completion only needs names and never resolves. This also
aligns the config hash of scale-created containers with up-created
ones.

Signed-off-by: Guillaume Lours <[email protected]>
2026-07-30 11:38:47 +02:00
Guillaume Lours 7bdc31c5de fix(config): apply config flags to --services/--volumes/--networks/--models/--hash
The runServices, runVolumes, runNetworks, runModels and runHash paths
called ProjectOptions.ToProject directly, bypassing the configOptions
wrapper that applies --no-consistency, --no-interpolate, --no-normalize,
--no-path-resolution, --profile filtering and env_file discarding.
Restore the variadic wrapper (mirroring configOptions.ToModel) and route
the five call sites through it.

Regression introduced by b80bb0586 (LoadProject API migration).

Fixes #13974

Signed-off-by: Guillaume Lours <[email protected]>
2026-07-30 11:38:20 +02:00
Guillaume Lours 367f1d5701 fix(cp): return non-nil Content from dry-run CopyFromContainer
The caller in pkg/compose/cp.go unconditionally defers
res.Content.Close() once the call succeeds. The dry-run client
returned a zero-value result with a nil Content reader, so
`docker compose cp --dry-run <ctr>:<path> <dst>` panicked with a
nil pointer dereference. Return an empty NopCloser instead, matching
the pattern already used for the other stream results in this file.

Signed-off-by: Guillaume Lours <[email protected]>
2026-07-30 11:37:49 +02:00
Nicolas De LoofandClaude Opus 4.8 aa518b9c3a Force-pull pre_start hook images under pull_policy: always
addPreStartHookPulls skipped any hook image already present locally,
regardless of pull policy. As a result a service with pull_policy: always
had its own image force-pulled on every up while its pre_start hook images
were left stale — diverging from both the service image and the `pull`
command path (which already re-pulls hooks under always).

Skip the "already present" shortcut when the parent service is
pull_policy: always, so hook images get the same force-pull treatment.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Nicolas De Loof <[email protected]>
2026-07-30 10:40:06 +02:00
Nicolas De Loof 1cc5120af8 Dedup pre_start hook images against service and each other
Address review feedback on pre_start hook image resolution:

1. GetDependentImages now skips a hook image equal to the service image
   (resolved via GetImageNameOrDefault), so `config --images` no longer
   prints a duplicate line and pullRequiredImages no longer schedules a
   redundant pull for it.

2. pullRequiredImages (up/create path) now dedups dependent images by
   reference via a `scheduled` set, so several hooks/services sharing the
   same missing image don't schedule concurrent redundant pulls. The hook
   pass moved to a helper (addPreStartHookPulls) to keep complexity in check.

3. The `pull` command no longer skips hook images under `pull_policy: build`.
   A hook image is a registry image that can't be built, so only `never`
   justifies skipping it — making `pull` consistent with the `up` path.

Signed-off-by: Nicolas De Loof <[email protected]>
2026-07-30 10:40:06 +02:00
Nicolas De Loof c9266e6297 Resolve pre_start hook images alongside service images
pre_start hooks run as ephemeral init containers with their own image
(ServiceHook.Image), but that image was ignored by image resolution:
`config --images` didn't list it, `pull` didn't fetch it, and `up` failed
at runtime with "No such image" when it wasn't already present locally.

Add a GetDependentImages helper that returns a service's pre_start hook
images, and use it wherever service images are collected/pulled:
getLocalImagesDigests, pullRequiredImages (up path), the pull command, and
`config --images`. Hook images inherit the parent service pull policy.

post_start/pre_stop hooks run via ExecCreate inside the service container
and never use hook.Image, so they are intentionally out of scope.

Digest resolution/locking (--resolve-image-digests / --lock-image-digests)
is not covered: compose-go's WithImagesResolved only resolves service.Image
(needs an upstream change), and the --lock-image-digests override merges
pre_start by concatenation, which would duplicate hooks.

Signed-off-by: Nicolas De Loof <[email protected]>
2026-07-30 10:40:06 +02:00
Nicolas De LoofandClaude Opus 4.8 e1131ad655 refactor(reconcile): aggregate observed resources, resolve conflicts in reconcile
collectObservedState indexed networks/volumes by compose label into a
single-valued map, so two live resources sharing a label (e.g. a leftover
after a rename) collided and the "winner" depended on the daemon's list
order — a nondeterministic `up` (spurious create/recreate events, possible
churn) on subsequent runs.

Make collection lossless and move the selection into the reconciler:

- ObservedState.Networks/Volumes become map[string][]Observed*: collection
  records every label-sharing resource and makes no premature choice.
- selectNetwork/selectVolume deterministically pick the resource matching
  the desired name (else the lexicographically smallest), returning the
  others as orphans.
- reconcile resolves the observed state once (resolveObserved) into
  single-valued resolvedNetworks/resolvedVolumes used everywhere, and warns
  about orphans instead of acting on them — they are left untouched because
  removing them could drop data or break unrelated workloads.

Adds selection unit tests, a collector aggregation test and a reconcile
conflict test (deterministic no-op + orphan warning across list orders).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Nicolas De Loof <[email protected]>
2026-07-27 14:56:25 +02:00
Nicolas De LoofandClaude Opus 4.8 ba2358c98c feat(reconcile): best-effort old-network removal on rename
A network rename does not require removing the old network — the new one
has a different name and is created independently. Yet the old removal
could block the whole operation: NetworkRemove fails when non-Compose
containers are still attached, and CreateNetwork depended on it.

Split the rename path from the same-name divergence path:

- Rename: CreateNetwork no longer depends on RemoveNetwork; the container
  migration proceeds regardless. RemoveNetwork is marked best-effort and,
  if the network is still in use (reported as a conflict), is skipped with
  a warning instead of failing. Any other error (transport, Moby API) is
  still propagated.
- Same-name divergence keeps the mandatory remove-before-create ordering.

Adds an Operation.BestEffort flag, honored by execRemoveNetwork, plus
reconcile and executor tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Nicolas De Loof <[email protected]>
2026-07-27 14:56:25 +02:00
Nicolas De LoofandClaude Opus 4.8 d764fee527 fix(reconcile): retry network create on conflict, keep owned config-hash
Address review findings on the network reconcile migration:

- createNetwork now treats a NetworkCreate conflict as success. A
  concurrent `docker compose up|run` can create the same network in the
  TOCTOU window between the observed-state snapshot and the create call;
  the previous ensureNetwork retried on conflict, the plain create must
  not fail hard.

- discoverUnmanagedNetworks/Volumes preserve the config-hash when the live
  resource is owned by this project (project label present, key label
  absent — e.g. written by an older Compose) so genuine divergence is
  still detected. For resources we don't own the hash stays empty and they
  are reused untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Nicolas De Loof <[email protected]>
2026-07-27 14:56:25 +02:00
Nicolas De LoofandClaude Opus 4.8 f3647227b6 feat(reconcile): migrate containers on network rename
Treat a network rename (observed.Name != desired.Name) as a recreation
rather than an additive create: the old network is removed, the new one
created, and attached containers are migrated onto it (reconnected), so
they no longer stay on the previous network until recreated for another
reason.

Networks carry no data, so removing the previous network — instead of
leaving it dangling alongside the new one under the same compose label —
is safe and keeps subsequent runs deterministic. This is a marginal
behavior change from previous Compose releases (which created the new
network and left the old attachments in place) in exchange for the more
logical outcome.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Nicolas De Loof <[email protected]>
2026-07-27 14:56:25 +02:00
Nicolas De LoofandClaude Opus 4.8 0723f71021 feat(reconcile): model network lifecycle in the plan
Mirror the volume reconciliation work (#13962) for networks: move network
divergence detection and recreation out of the imperative pre-reconcile
path (ensureNetwork/resolveOrCreateNetwork/removeDivergedNetwork) into the
reconciliation plan.

- reconcileNetworks now owns creation of missing networks and, for a
  network whose config-hash diverged, an explicit recreation sequence
  (no user confirmation: recreating a network is not destructive):
  stop containers -> disconnect -> remove network -> create network ->
  reconnect containers. Attached containers keep their identity (they are
  reconnected, not recreated), matching the previous behavior. If a
  container is independently recreated by reconcileContainers, its removal
  is ordered after the reconnect so they don't race.
- Renaming a network creates the new one additively and leaves the old one
  untouched.
- collectObservedState discovers legacy/unlabeled networks by name and
  records them as unmanaged matches (empty config-hash) so the reconciler
  reuses them untouched; ownership warnings move to warnUnmanagedNetworks.
  checkExternalNetworks keeps external-network validation/resolution.
- execCreateNetwork now issues a plain createNetwork; the imperative
  ensureNetwork/resolveOrCreateNetwork/removeDivergedNetwork and the
  connect/disconnect helpers are removed.

Adds reconcile, observed-state and executor tests covering network
create/diverge/rename, the entangled diverge+recreate case, legacy
by-name discovery and the ownership warnings.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Nicolas De Loof <[email protected]>
2026-07-27 14:56:25 +02:00
Max Proske 54e0373f1c Tolerate missing env file on runtime commands
Signed-off-by: Max Proske <[email protected]>
2026-07-27 09:20:14 +02:00
Guillaume Lours 37dea37d67 fix(config): pin type:image volume sources and pre_start hook images
Rely on compose-go WithImagesResolved, which now resolves dependent
images — `type: image` volume sources and pre_start hook images —
with its already-digested guard, per-call memoization and
sibling-service detection (compose-spec/compose-go#894, #899), rather
than duplicating resolution logic CLI-side. The interpolated path gets
this for free; --no-interpolate maps the raw model onto a
pseudo-project keyed by service names to reuse the same resolution,
and --lock-image-digests keeps type:image volumes in its output.
pre_start hooks can't be carried into the lock override (hook lists
are appended on merge), so generating a lock warns that hook images
stay unpinned there.
As a side effect, `compose publish` now fails fast on unresolvable
dependent images.

Fixes #13827

Signed-off-by: Guillaume Lours <[email protected]>
2026-07-24 15:33:21 +02:00
Nicolas De LoofandClaude Opus 4.8 69b2f69d31 fix(reconcile): migrate containers to the renamed volume within the same up
The additive rename path created the new volume but kept the old name in
the observed state, so hasVolumeMismatch never fired: existing containers
stayed on the old volume while fresh replicas mounted the new one
(split-brain), and later runs picked a nondeterministic winner between the
two equally labelled volumes.

Rewrite the observed volume name to the desired one after planning the
"renamed" create, so reconcileContainers migrates the existing containers
onto the new volume in the same up — restoring parity with the old
ensureVolume path — while still leaving the old volume and its data intact.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Nicolas De Loof <[email protected]>
2026-07-23 16:17:43 +02:00
Nicolas De LoofandClaude Opus 4.8 601be0f094 fix(reconcile): preserve backward compatibility for legacy volumes
Two edge regressions from the switch to a label-scoped observed state,
both reported against the old ensureVolume path:

- A same-named volume created manually or by another project (no compose
  label) was invisible to the observed state, so a VolumeCreate was
  planned on every up: a hard failure if the driver differed, spurious
  Creating/Created events otherwise. collectObservedState now discovers
  such volumes by name (pre-label Compose semantics) and records them as
  unmanaged matches with an empty config-hash, so the reconciler reuses
  them untouched. The ownership warnings move to warnUnmanagedVolumes,
  driven off the observed state; checkVolumes shrinks to external-only
  validation (checkExternalVolumes).

- Renaming a volume hit the diverged path and, with up -y, deleted the
  old volume and its data (VolumeHash includes Name), where it previously
  just created the new one. When observed.Name != desired.Name the volume
  is now created additively, leaving the old one untouched, with no prompt.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Nicolas De Loof <[email protected]>
2026-07-23 16:17:43 +02:00
Nicolas De LoofandClaude Opus 4.8 b45991bf47 fix(reconcile): remove volumes_from consumers before volume recreation
servicesUsingVolume only matched services mounting the volume directly, so
a service reaching it through volumes_from was not stopped/removed before
RemoveVolume. Docker materializes the inherited mount on the consumer's
container, so its removal would fail with "volume in use". Compute the
transitive volumes_from closure so every container referencing the volume
is removed first. (network_mode/ipc/pid: service:x share namespaces, not
mounts, and are intentionally excluded.)

Also reassign the result of Labels.Add in createVolume: it mutates in
place only when the map is non-nil, so discarding the return would drop
the config-hash label for a volume with no CustomLabels.

Addresses review feedback: documents why observed.Containers is cleared
without touching the observedContainersByService hashing snapshot, and
strengthens the cascade tests to assert the full plan ordering.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Nicolas De Loof <[email protected]>
2026-07-23 16:17:43 +02:00
Nicolas De LoofandClaude Opus 4.8 44ac2c94e9 feat(reconcile): model volume recreation in the plan
Move volume divergence detection and recreation out of the imperative
pre-reconcile path (ensureVolume/removeDivergedVolume) and into the
reconciliation plan, activating the dormant planRecreateVolume seam.

A diverged volume now produces an explicit, forward-only sequence:
stop containers -> remove containers -> remove volume -> create volume
-> create containers. Container re-creation is delegated to
reconcileContainers (affected services are cleared from the observed
snapshot so they are scheduled fresh, gated on the CreateVolume node),
and the recreation cascades to namespace/volume-sharing dependents.

User confirmation (recreate, data will be lost) is consulted while
building the plan via reconciler.prompt; declining leaves the volume
untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Nicolas De Loof <[email protected]>
2026-07-23 16:17:43 +02:00
Domantas PetrauskasandClaude Opus 4.8 5534be0a28 fix(oci): honor --insecure-registry when up re-loads the model
`docker compose -f oci://<insecure-registry>/... up` failed against a
plain-HTTP registry unless --yes was passed:

    failed to pull OCI resource "localhost:5000/test:interpolated":
    Head "https://localhost:5000/v2/test/manifests/interpolated":
    http: server gave HTTP response to HTTPS client

`up` loads the project twice. The first load goes through ToProject,
which built its OCI options from --insecure-registry correctly. Without
--yes, checksForRemoteStack then calls promptForInterpolatedVariables,
which re-loads the project through ToModel to list the interpolation
variables. That second load builds its own resource loaders via
remoteLoaders, and those passed an empty api.OCIOptions{}, dropping the
flag. Since the OCI loader always performs a network resolve, the
re-load spoke HTTPS to a plain-HTTP registry and failed before the
prompt could be shown.

The two construction sites had drifted apart, so rather than patching
the second one, both now share ProjectOptions.ociOptions(). `config`
and `viz` use the same ToModel path and are fixed as well.

Covered by an e2e case in TestPublish, which already runs an insecure
registry and an oci:// round-trip: it publishes a fixture carrying an
interpolation variable so the prompt fires, then runs `up` without
--yes and declines, asserting the re-load does not fail with
"server gave HTTP response to HTTPS client".

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Domantas Petrauskas <[email protected]>
2026-07-21 16:24:34 +02:00
Guillaume Lours fd794ea842 fix(build): use platform image-manifest digest, not attested index
With the containerd image store and BuildKit provenance attestations
(the default), a built image is stored as an attested index whose
top-level digest also covers the attestation manifest. That digest
churns on every build even when the runnable content is unchanged,
so compose recreated containers on every `up --build`.

Compare the digest of the "image" kind manifest instead, selected for
the target platform and restricted to locally available manifests, so
it is deterministic and reflects only config + layers. Both the build
and up sides of the staleness check go through the same selection, and
registry-only images keep the Bake-reported digest.

Fixes #13636

Signed-off-by: Guillaume Lours <[email protected]>
2026-07-20 12:15:42 +02:00
Guillaume Lours efb63f2e6e fix(config): warn when service selection is silently ignored
`docker compose config --no-interpolate <service>` and
`docker compose config --variables <service>` load the raw model
without applying service filtering, so the full model is rendered
regardless of the services passed as arguments. Filtering will not
be supported on these paths, so emit a warning to make sure users
are no longer misled by silently ignored arguments.

Fixes #13614

Signed-off-by: Guillaume Lours <[email protected]>
2026-07-17 16:12:42 +02:00
Junhao Liao 536d8f331d fix(reconcile): preserve zero-replica services during hashing
Signed-off-by: Junhao Liao <[email protected]>
2026-07-16 15:19:50 +02:00
blackflytech ff711700cd Fix grammar in Attestations field comment
Signed-off-by: blackflytech <[email protected]>
2026-07-06 10:36:46 +02:00
Guillaume Lours 9d444a667a pre_start: support pre_start lifecycle hooks
runPreStart executes a service's pre_start hooks sequentially as
ephemeral containers that share the first non-running replica's
volumes via VolumesFrom and attach to the same networks. A non-zero
hook exit gates service start.

per_replica: false is the only currently supported mode; per_replica:
true is rejected up front. The donor replica is the lowest-numbered
one so the choice is deterministic. ContainerWait uses
WaitConditionNextExit, and the wait loop deterministically handles
the daemon's clean-close (nil on Error + exit code on Result) and
transport-error races to avoid spurious hook failures.

The log stream is opened before ContainerStart to avoid racing
AutoRemove on fast-exiting hooks, and runs under a derived context
so a daemon that keeps the connection open cannot deadlock the call.
Hook containers carry project/service/version labels; the two
cleanup paths force-remove the never-started container explicitly
and warn when removal fails.

pre_start runs once per service when no replica is already running
(initial up, force-recreate or spec change), and is skipped on
scale-up so additional replicas don't re-trigger the hooks.

Coverage: 11 unit tests (including scheduler-race stress) with
goroutine-leak verification via goleak, plus 10 E2E tests (success
path, hook failure gating start, build-image inheritance, idempotent
re-up, spec change, force-recreate, mid-sequence failure, ordering,
scale-up, scaled service).

Signed-off-by: Guillaume Lours <[email protected]>
2026-06-30 10:49:04 +02:00
Nick Janetakis 2a6a4e5179 Normalize --no-TTY flag to --no-tty
Signed-off-by: Nick Janetakis <[email protected]>
2026-06-29 20:56:31 +02:00
vmphase 0a56eeba3c fix(compose/port): show private port in portNotFoundError message
Signed-off-by: vmphase <[email protected]>
2026-06-29 18:51:14 +02:00
Guillaume Lours 55c61ceef9 fix(reconcile): hash resolved service refs to match executor
The reconciler hashed the raw service config while the executor
hashed the form with network_mode/ipc/pid/volumes_from references
resolved to container IDs. Persisted hash and recomputed hash
never matched, so dependents were recreated on every `up`.

Resolve references against observed containers before hashing,
and cascade recreation to namespace-sharing dependents when a
parent is replaced — otherwise the dependent would keep a stale
"container:<old_id>" reference. Also dedup stops in
planStopDependents via stoppedByPlan: with the cascade restored,
the dependent would otherwise receive two Stop nodes.

Fixes #13878.

Signed-off-by: Guillaume Lours <[email protected]>
2026-06-29 17:50:27 +02:00
Guillaume Lours ab0d7898de fix(run): scope Running events to project.Services
emitRunningEvents iterated the full ObservedState.Containers map,
which is intentionally broader than the operation scope (it covers
DisabledServices for orphan classification). compose run --no-deps
SERVICE leaves project.Services empty and moves every other service
to DisabledServices, so their running containers were reported as
Running even though this command must not manage them.

Filter the iteration by project.Services, matching the reconciler
scope, and document the contract on the function.

Fixes #13882

Signed-off-by: Guillaume Lours <[email protected]>
2026-06-29 15:10:14 +02:00
Ijtihed Kilani 9cd844243f fix(publish): honor env_file required: false for missing files
Signed-off-by: Ijtihed Kilani <[email protected]>
2026-06-23 15:11:58 +02:00
Yohta KimuraandClaude Opus 4.6 43922d55b0 Fix rawsetenv nil-pointer guard for inherit-from-shell env vars
When a service declares an env var without a value (e.g. `- KEY` or
`KEY:`), MappingWithEquals stores it as a nil *string. The previous
condition `existing != nil && ...` skipped the warning for this case,
allowing silent overwrites. Change to `existing == nil || ...` so the
warning fires for both nil (shell-inherit) and value-mismatch cases.

Add e2e tests for both list-style (`- KEY`) and map-style (`KEY:`)
YAML forms to lock in the behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Signed-off-by: Yohta Kimura <[email protected]>
2026-06-23 15:01:33 +02:00
Yohta KimuraandClaude Opus 4.8 5c9d611b5f Handle rawsetenv collisions with overwrite and warning
rawsetenv injects provider variables without the service-name prefix, so
a key can collide with a value already set on the dependent service,
whether declared by the user in environment or emitted by another
provider. Log a warning and overwrite on collision, document the
precedence and the non-deterministic ordering between concurrent
providers, and cover the user-environment override with an e2e test.

Signed-off-by: Yohta Kimura <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-23 15:01:33 +02:00