compose/pkg/compose
Guillaume Lours 9d444a667a
Some checks failed
ci / validate (lint) (push) Has been cancelled
ci / validate (validate-docs) (push) Has been cancelled
ci / validate (validate-go-mod) (push) Has been cancelled
ci / validate (validate-headers) (push) Has been cancelled
ci / binary (push) Has been cancelled
ci / bin-image-test (push) Has been cancelled
ci / test (push) Has been cancelled
ci / e2e (plugin, oldstable) (push) Has been cancelled
ci / e2e (standalone, oldstable) (push) Has been cancelled
ci / e2e (plugin, stable) (push) Has been cancelled
ci / e2e (standalone, stable) (push) Has been cancelled
merge / bin-image-prepare (push) Has been cancelled
merge / module-image (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
ci / binary-finalize (push) Has been cancelled
ci / coverage (push) Has been cancelled
ci / release (push) Has been cancelled
merge / bin-image (push) Has been cancelled
merge / desktop-edge-test (push) Has been cancelled
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 <glours@users.noreply.github.com>
2026-06-30 10:49:04 +02:00
..
testdata publish env_file references as opaque hash to prevent paths conflicts 2025-10-22 19:32:16 +02:00
transform Bump compose go to v2.10.0 2025-12-01 17:19:40 +01:00
api_versions.go fix: gate extra EndpointsConfig behind API >= 1.44 2026-03-31 15:44:00 +02:00
apiSocket.go Introduce abstractions to support SDK usage without requiring Docker CLI 2025-10-27 16:17:50 +01:00
attach.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
attach_service.go golangci-lint: use gci formatter instead of goimports 2025-12-01 12:21:50 +01:00
build.go compose: recreate container when mounted image digest changes 2026-01-26 15:55:44 +01:00
build_bake.go watch: do not rebuild depends_on services on file change 2026-06-19 11:23:50 +02:00
build_classic.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
build_test.go fix: preserve ssh:// URL scheme in dockerFilePath 2026-03-27 10:12:59 +01:00
commit.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
compose.go refactor: merge RuntimeVersion and CurrentAPIVersion into RuntimeAPIVersion 2026-03-31 14:39:37 +02:00
container.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
containers.go pre_start: support pre_start lifecycle hooks 2026-06-30 10:49:04 +02:00
convergence.go pre_start: support pre_start lifecycle hooks 2026-06-30 10:49:04 +02:00
convergence_test.go refactor: miscellaneous small cleanups (forEach, filters, Set) 2026-05-12 11:31:40 +02:00
convert.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
cp.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
create.go fix(run): scope Running events to project.Services 2026-06-29 15:10:14 +02:00
create_test.go fix: gate extra EndpointsConfig behind API >= 1.44 2026-03-31 15:44:00 +02:00
dependencies.go refactor(compose): remove redundant wrapper funcs in dependencies.go 2026-05-12 11:31:40 +02:00
dependencies_test.go fix mixed assertion libraries in tests 2026-03-31 17:32:51 +02:00
desktop.go refactor: drop Desktop beta-settings check; gate hint on LogsTab flag 2026-05-18 17:28:03 +02:00
docker_cli_providers.go Introduce abstractions to support SDK usage without requiring Docker CLI 2025-10-27 16:17:50 +01:00
down.go refactor: fix lint issues from cleanup changes 2026-05-12 11:31:40 +02:00
down_test.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
envresolver.go format code with gofumpt 2024-12-17 16:50:14 +01:00
envresolver_test.go
events.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
exec.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
executor.go executor: split into ops + events files 2026-06-08 20:14:38 +02:00
executor_events.go executor: split into ops + events files 2026-06-08 20:14:38 +02:00
executor_ops.go executor: split into ops + events files 2026-06-08 20:14:38 +02:00
executor_test.go executor: pay down technical debt from PE review 2026-06-08 20:14:38 +02:00
export.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
filters.go nit: use labelFilter consistently in filters.go 2026-05-12 11:31:40 +02:00
generate.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
hash.go Recreate container on volume configuration change 2024-12-12 19:11:00 +01:00
hash_test.go
hook.go fix: use pointer receivers for composeService methods with sync.Once fields 2026-03-31 14:39:37 +02:00
hook_test.go fix: add build tag to hook_test.go to fix Windows build failure (#13682) 2026-03-30 16:06:26 +02:00
image_pruner.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
images.go refactor: merge RuntimeVersion and CurrentAPIVersion into RuntimeAPIVersion 2026-03-31 14:39:37 +02:00
images_test.go pkg/compose: use negotiated API version for request shaping 2026-03-31 14:39:37 +02:00
kill.go refactor(compose): extract forEachContainerConcurrent to deduplicate pause/kill logic 2026-05-12 11:31:40 +02:00
kill_test.go refactor: fix lint issues from cleanup changes 2026-05-12 11:31:40 +02:00
loader.go restore support for COMPOSE_COMPATIBILITY 2025-12-07 18:42:04 +01:00
loader_test.go fix mixed assertion libraries in tests 2026-03-31 17:32:51 +02:00
logs.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
logs_test.go refactor: fix lint issues from cleanup changes 2026-05-12 11:31:40 +02:00
ls.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
ls_test.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
model.go use new moby/moby modules instead of docker/docker dependency 2026-04-08 08:50:50 +02:00
monitor.go refactor: miscellaneous small cleanups (forEach, filters, Set) 2026-05-12 11:31:40 +02:00
observed_state.go fix(run): scope Running events to project.Services 2026-06-29 15:10:14 +02:00
observed_state_test.go fix(run): scope Running events to project.Services 2026-06-29 15:10:14 +02:00
pause.go refactor(compose): extract forEachContainerConcurrent to deduplicate pause/kill logic 2026-05-12 11:31:40 +02:00
plan.go executor: explicit rename data flow + containers-by-service cache 2026-06-08 20:14:38 +02:00
plan_test.go tests: cover depends_on chaining and OpRunProvider stringer 2026-06-08 20:14:38 +02:00
plugins.go Fix rawsetenv nil-pointer guard for inherit-from-shell env vars 2026-06-23 15:01:33 +02:00
plugins_test.go fix: stop-only metadata no longer drops options for up/down 2026-05-18 11:11:38 +02:00
plugins_windows.go append .exe to provider name doing executable lookup on windows 2025-05-14 17:19:35 +02:00
port.go fix(compose/port): show private port in portNotFoundError message 2026-06-29 18:51:14 +02:00
pre_start.go pre_start: support pre_start lifecycle hooks 2026-06-30 10:49:04 +02:00
pre_start_test.go pre_start: support pre_start lifecycle hooks 2026-06-30 10:49:04 +02:00
printer.go next release will be major version v5.x 2025-11-13 09:32:43 +01:00
progress.go fix: restore stoppingEvent/stoppedEvent helpers for plugin stop hook 2026-05-18 15:12:39 +02:00
ps.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
ps_test.go refactor: fix lint issues from cleanup changes 2026-05-12 11:31:40 +02:00
publish.go fix(publish): honor env_file required: false for missing files 2026-06-23 15:11:58 +02:00
publish_test.go fix(publish): honor env_file required: false for missing files 2026-06-23 15:11:58 +02:00
pull.go chore: fix some comments to improve readability 2026-06-09 11:45:13 +02:00
push.go modernize some code 2026-02-12 15:31:35 +01:00
reconcile.go fix(reconcile): hash resolved service refs to match executor 2026-06-29 17:50:27 +02:00
reconcile_test.go fix(reconcile): hash resolved service refs to match executor 2026-06-29 17:50:27 +02:00
remove.go refactor: fix lint issues from cleanup changes 2026-05-12 11:31:40 +02:00
restart.go refactor(compose): collapse trivial event-helper wrappers in progress.go 2026-05-12 11:31:40 +02:00
run.go chore: fix some comments to improve readability 2026-06-09 11:45:13 +02:00
scale.go golangci-lint: use gci formatter instead of goimports 2025-12-01 12:21:50 +01:00
secrets.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
shellout.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
start.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
stop.go perf: avoid duplicate provider metadata fetch on stop 2026-05-18 11:11:38 +02:00
stop_test.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
suffix_unix.go append .exe to provider name doing executable lookup on windows 2025-05-14 17:19:35 +02:00
top.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
up.go feat: add Docker Desktop Logs view hints and navigation shortcut 2026-04-10 15:26:08 +02:00
up_test.go Fix up attach filtering 2026-03-25 10:07:02 +01:00
viz.go golangci-lint: use gci formatter instead of goimports 2025-12-01 12:21:50 +01:00
viz_test.go fix mixed assertion libraries in tests 2026-03-31 17:32:51 +02:00
volumes.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
volumes_test.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
wait.go go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2 2026-02-11 12:32:37 +01:00
watch.go watch: do not rebuild depends_on services on file change 2026-06-19 11:23:50 +02:00
watch_test.go fix mixed assertion libraries in tests 2026-03-31 17:32:51 +02:00