Commit Graph
1432 Commits
Author SHA1 Message Date
Guillaume Lours 672dc14d29 feat: add stop lifecycle hook for external providers
Provider-backed services were silently skipped on `docker compose stop`,
leaving external resources running after the user expected the stack to
be paused (e.g. after Ctrl+C during `up --watch`).

Compose now invokes `<provider> compose stop <service>` for providers
that advertise a `stop` block in their `metadata` subcommand output.
Providers that do not advertise stop (or do not implement metadata at
all) are silently skipped, preserving backward compatibility with
existing providers that pre-date this hook.

Closes #13772

Signed-off-by: Guillaume Lours <[email protected]>
2026-05-18 11:11:38 +02:00
Guillaume Lours 8e0d5e17a7 fix: make e2e tests pass reliably locally with Docker Desktop
- Fix stale image/container reuse across test runs                                                                                                                                                                                                                                                          - Add registry readiness check and async removal polling
  - Skip multi-arch test when docker driver supports it
  - Use t.Cleanup for reliable teardown, fix project name mismatches
  - Re-enable 4 previously skipped tests that now pass

Signed-off-by: Guillaume Lours <[email protected]>
2026-05-18 10:55:41 +02:00
Guillaume Lours 66c21c3b6c fix: route OCI artifact pulls through Docker Desktop HTTP proxy
The compose process performs OCI artifact fetches in-process via
containerd's docker resolver, whose default transport only honors
HTTP_PROXY/HTTPS_PROXY/NO_PROXY env vars. Users behind PAC-only
corporate proxies hit i/o timeouts on `oci://` includes and on
`compose publish`.

When Docker Desktop is the active engine and exposes httpproxy.sock,
route the resolver through it (PAC-aware). Falls back to the default
transport when DD is unavailable or the socket is missing. Modeled on
docker/mcp-gateway PR #354.

Signed-off-by: Guillaume Lours <[email protected]>
2026-05-18 10:53:23 +02:00
Nicolas De loof 659b269e52 nit: use labelFilter consistently in filters.go
Signed-off-by: Nicolas De loof <[email protected]>
2026-05-12 11:31:40 +02:00
Nicolas De loof 5c70712199 fix: restore deprecated Set.Clear/Union; use resource var in pull.go
Assisted-By: docker-agent
Signed-off-by: Nicolas De loof <[email protected]>
2026-05-12 11:31:40 +02:00
Nicolas De loof 07832c4df1 refactor: fix lint issues from cleanup changes
Assisted-By: docker-agent
Signed-off-by: Nicolas De loof <[email protected]>
2026-05-12 11:31:40 +02:00
Nicolas De loof 40d363baf9 refactor: miscellaneous small cleanups (forEach, filters, Set)
Assisted-By: docker-agent
Signed-off-by: Nicolas De loof <[email protected]>
2026-05-12 11:31:40 +02:00
Nicolas De loof 98163f5616 refactor(compose): collapse resolveSharedNamespaces repeated blocks
Assisted-By: docker-agent
Signed-off-by: Nicolas De loof <[email protected]>
2026-05-12 11:31:40 +02:00
Nicolas De loof 96cb057d04 refactor(compose): extract forEachContainerConcurrent to deduplicate pause/kill logic
Assisted-By: docker-agent
Signed-off-by: Nicolas De loof <[email protected]>
2026-05-12 11:31:40 +02:00
Nicolas De loof c8325dd0d4 refactor(compose): extract removeResource helper in down.go
Assisted-By: docker-agent
Signed-off-by: Nicolas De loof <[email protected]>
2026-05-12 11:31:40 +02:00
Nicolas De loof 0eb2e4f4e0 refactor(compose): remove redundant wrapper funcs in dependencies.go
Assisted-By: docker-agent
Signed-off-by: Nicolas De loof <[email protected]>
2026-05-12 11:31:40 +02:00
Nicolas De loof da530c7233 refactor(compose): collapse trivial event-helper wrappers in progress.go
Assisted-By: docker-agent
Signed-off-by: Nicolas De loof <[email protected]>
2026-05-12 11:31:40 +02:00
Sebastiaan van Stijn 88545507e8 pkg/compose: go fix
Signed-off-by: Sebastiaan van Stijn <[email protected]>
2026-05-11 13:40:24 +02:00
Guillaume Lours 9eb8966705 fix: provider output handling and watch rebuild re-invocation
Provider info and error messages containing newlines broke the TTY
progress display (timer drifting to a new line, broken cursor
movement). Extract only the first line for progress events via
firstLine(). Full messages remain available through the provider's
own debug message type.

Skip provider services during watch rebuild convergence by adding a
SkipProviders flag to CreateOptions, set only by the watch rebuild
path. This prevents unnecessary re-invocation of providers on every
file change while preserving normal provider execution for all other
commands (up, create, run, scale).

Signed-off-by: Guillaume Lours <[email protected]>
2026-04-14 11:43:48 +02:00
Guillaume LoursandClaude Opus 4.6 182defa8aa feat: add Docker Desktop Logs view hints and navigation shortcut
Add CLI hooks handler to show "What's next:" hints pointing to the
Docker Desktop Logs view after `docker logs`, `docker compose logs`,
and `docker compose up -d`.

Add `l` keyboard shortcut in the `compose up` navigation menu to
open the Logs view, gated on Docker Desktop feature flag and settings.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Signed-off-by: Guillaume Lours <[email protected]>
2026-04-10 15:26:08 +02:00
Guillaume Lours ba417e4392 use new moby/moby modules instead of docker/docker dependency
Signed-off-by: Guillaume Lours <[email protected]>
2026-04-08 08:50:50 +02:00
Sebastiaan van Stijn 89e3517f29 build(deps): bump github.com/docker/cli v29.4.0
full diff: https://github.com/docker/cli/compare/v29.3.1...v29.4.0

Signed-off-by: Sebastiaan van Stijn <[email protected]>
2026-04-07 12:21:18 +02:00
Ishwar 1e3f4d0f4a fix: update e2e tests to expect exit code 130 on user decline
Signed-off-by: Ishwar <[email protected]>
2026-03-31 20:35:07 +02:00
Ishwar 37cbf7a9cd test: repurpose decline test to cover sensitive data detection path
Renames test to Test_preChecks_sensitive_data_detected_decline. Uses a temporary .env file with an AWS token to reliably trigger the DefangLabs secret detector, and confirms that preChecks correctly aborts early on user decline.

Signed-off-by: Ishwar <[email protected]>
2026-03-31 20:35:07 +02:00
Ishwar 9c5fd50989 publish: return ErrPublishAborted when user declines interactive prompts
Signed-off-by: Ishwar <[email protected]>
2026-03-31 20:35:07 +02:00
Ricardo Branco 73d8a6d57d test: use random host port for dind TLS build test
Signed-off-by: Ricardo Branco <[email protected]>
2026-03-31 19:10:35 +02:00
Sebastiaan van Stijn 92a7ac1fa2 fix mixed assertion libraries in tests
Before this, assertion libraries were mixed, sometimes
even in the same file.

    git grep -l '"gotest.tools/v3/' | wc -l
    75
    git grep -l '"github.com/stretchr/testify' | wc -l
    24

Signed-off-by: Sebastiaan van Stijn <[email protected]>
2026-03-31 17:32:51 +02:00
jarek a97738de7d fix: add NetworkConnect fallback for API < 1.44
For Docker daemons older than API 1.44, the extra networks omitted from
ContainerCreate must be connected individually after creation via
NetworkConnect. If any NetworkConnect call fails, remove the freshly
created container to prevent orphans.

Add two tests:
- TestCreateMobyContainerLegacyAPI: happy path verifying NetworkConnect
  is called for the secondary network on API 1.43
- TestCreateMobyContainerLegacyAPI_NetworkConnectFailure: verifies
  ContainerRemove is called with Force when NetworkConnect fails

Signed-off-by: jarek <[email protected]>
2026-03-31 15:44:00 +02:00
jarek 3b1004c4d9 fix: gate extra EndpointsConfig behind API >= 1.44
Before API 1.44 (Docker Engine 25.0), ContainerCreate only accepted a
single EndpointsConfig entry. Passing multiple entries silently drops
all but one network, leaving containers under-connected on older daemons
such as Docker 20.10 or Synology DSM 7.1/7.2.

Add apiVersion144 constant and wrap the secondary-networks loop in
defaultNetworkSettings so that only the primary network is included in
the ContainerCreate call when the negotiated API version is below 1.44.

Signed-off-by: jarek <[email protected]>
2026-03-31 15:44:00 +02:00
Guillaume LoursandClaude Opus 4.6 9cab43945a refactor: merge RuntimeVersion and CurrentAPIVersion into RuntimeAPIVersion
After API negotiation, Compose should only rely on the negotiated version
and never use the daemon's raw max version for request shaping. Merge both
functions into a single RuntimeAPIVersion that negotiates via Ping and
returns ClientVersion, erroring if the client reports an empty version
instead of silently falling back to ServerVersion.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Signed-off-by: Guillaume Lours <[email protected]>
2026-03-31 14:39:37 +02:00
Guillaume LoursandClaude Opus 4.6 ef836856fe fix: don't cache transient errors in version negotiation
Replace sync.Once with sync.Mutex so that only successful version
lookups are cached. Errors (context cancellation, network blips) are
returned without caching, allowing subsequent calls to retry.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Signed-off-by: Guillaume Lours <[email protected]>
2026-03-31 14:39:37 +02:00
Guillaume LoursandClaude Opus 4.6 c7d1a6030e fix: use pointer receivers for composeService methods with sync.Once fields
Moving runtimeVersionCache from a package-level var to instance fields on
composeService caused copylocks violations in methods using value receivers,
since sync.Once contains sync.noCopy. Switch the 4 affected methods to
pointer receivers.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Signed-off-by: Guillaume Lours <[email protected]>
2026-03-31 14:39:37 +02:00
Guillaume LoursandClaude Opus 4.6 5f6f35ed22 pkg/compose: use negotiated API version for request shaping
Move runtimeVersionCache from a package-level var to per-instance fields
on composeService and add CurrentAPIVersion() that negotiates via Ping
before returning the client version.

Switch getCreateConfigs and buildContainerVolumes to use
CurrentAPIVersion so that version-gated request shaping matches what
the daemon actually validates against (the negotiated API version from
the request path, not the server's max capability).

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Signed-off-by: Guillaume Lours <[email protected]>
2026-03-31 14:39:37 +02:00
pawannn e5c6b9c3b7 fix: return error from ExecStart instead of nil in runWaitExec
Signed-off-by: pawannn <[email protected]>
2026-03-30 16:06:26 +02:00
pawannn b529a3ca5b fix: add build tag to hook_test.go to fix Windows build failure (#13682)
Signed-off-by: pawannn <[email protected]>
2026-03-30 16:06:26 +02:00
Sebastiaan van Stijn 5bbdd239df pkg/compose: fix TestRunHook_ConsoleSize on macOS
containerd/console is broken on macOS, and panics; use creack/pty
instead for this test.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
2026-03-30 09:43:35 +02:00
Mohamed-Moumni e742d09711 fix: initialize and pass envFiles map in processExtends
Signed-off-by: Mohamed-Moumni <[email protected]>
2026-03-27 16:02:01 +01:00
Samaresh Kumar Singh 612b8c567e fix: preserve ssh:// URL scheme in dockerFilePath
filepath.Join cleans its arguments, collapsing the double slash in
ssh:// URLs to a single slash (ssh:/), corrupting the scheme before
it reaches buildx. Return the dockerfile as-is for any URL-schemed
context, matching the existing behaviour for git:// and https:// URLs.

Fixes the issue #13668

Signed-off-by: Samaresh Kumar Singh <[email protected]>
2026-03-27 10:12:59 +01:00
CodeLoopdroid a57320fdf5 Fix up attach filtering
Signed-off-by: CodeLoopdroid <[email protected]>
2026-03-25 10:07:02 +01:00
Ishwar b18354b9f4 refactor: thread context through publish sensitive data check
Signed-off-by: Ishwar <[email protected]>
2026-03-23 12:10:25 +01:00
Nicolas De Loof 5de4353a6a bump golangci-lint to latest and configure CLAUDE to use it on change
Signed-off-by: Nicolas De Loof <[email protected]>
2026-03-23 11:33:52 +01:00
Michael Irwin 4915b775ee fix: only pass ConsoleSize to ExecAttach when TTY is enabled
The moby/moby client (v0.2.2) validates that ConsoleSize is zero when
TTY is disabled, returning "console size is only supported when TTY is
enabled" otherwise. Previously, ConsoleSize was populated unconditionally
from GetTtySize(), which returns real terminal dimensions when Compose is
run interactively — causing post_start hooks to fail for services without
`tty: true`.

Fix by only reading and passing the console size when service.Tty is true.

Signed-off-by: Michael Irwin <[email protected]>

Resolves #13615
2026-03-04 19:53:35 +01:00
Varun Chawla 81d7d3c60b fix: execute post_start hooks in docker compose run
RunOneOffContainer was not executing post_start lifecycle hooks after
starting a container. This adds hook execution by listening for the
container's start event via the Docker Events API and running hooks
once the container is running, matching the behavior already present
in startService (used by docker compose up) and restart.

Signed-off-by: Varun Chawla <[email protected]>
2026-02-23 08:58:31 +01:00
Sebastiaan van Stijn f9828dfab9 modernize some code
Results of running the modernize command, with some minor changes
afterwards (removing the `contains` and `hasStatus` helper functions);

    go install golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest
    modernize -fix ./...

Signed-off-by: Sebastiaan van Stijn <[email protected]>
2026-02-12 15:31:35 +01:00
Sebastiaan van Stijn da691c7cc1 pkg/compose: un-export consts
These consts were added in b760afaf9f,
but are only user internal in the package. Given that the list of
consts may change over time, it's probably best to keep them internal
and not part of the module's API.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
2026-02-11 22:26:15 +01:00
Sebastiaan van Stijn fefdc95224 pkg/compose: defaultNetworkSettings: slight refactor
- use an intermediate serviceNetworks slice so that we don't have
  to call service.NetworksByPriority multiple times.
- shift the primary network from the slice (if any), so that
  we can drop some checks for "additional networks"
- group code related to setting up the primary network as first
  step, then append remaining networks.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
2026-02-11 15:14:49 +01:00
Sebastiaan van Stijn 08c32e9033 pkg/compose: defaultNetworkSettings: return early for unsupported feature
Signed-off-by: Sebastiaan van Stijn <[email protected]>
2026-02-11 15:14:49 +01:00
Sebastiaan van Stijn bdb630fb89 pkg/compose: format layer push progress
Format layer progress details with minimal efforts as new UI does
not render individual layers.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
2026-02-11 12:32:37 +01:00
Nicolas De Loof 3697b128a1 pkg/compose: format layer pull progress
Format layer progress details with minimal efforts as new UI
does not render individual layers

Signed-off-by: Nicolas De Loof <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
2026-02-11 12:32:37 +01:00
Sebastiaan van Stijn b285e48976 pkg/compose: remove unused consts
Signed-off-by: Sebastiaan van Stijn <[email protected]>
2026-02-11 12:32:37 +01:00
Sebastiaan van Stijn 8193d86d2f pkg/bridge: remove uses of go-connections
Signed-off-by: Sebastiaan van Stijn <[email protected]>
2026-02-11 12:32:37 +01:00
Sebastiaan van Stijn bfb5511d0d go.mod: bump github.com/moby/moby/api v1.53.0, moby/client v0.2.2
Also update TestDefaultNetworkSettings:
Test that the network with the highest priority is returned as
"primary" network, and other networks as extra networks.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
2026-02-11 12:32:37 +01:00
Sebastiaan van Stijn 8b769bad6b pkg/compose: remove dependency on github.com/docker/buildx/driver
The driver.Auth interface was describing the configfile.GetAuthConfig
implementation; define a local interface instead of using buildx's
definition as an intermediate.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
2026-01-29 15:59:03 +01:00
Nicolas De Loof 671507a8b3 fix panic
Signed-off-by: Nicolas De Loof <[email protected]>
2026-01-29 09:57:49 +01:00
ibrahim yapar 56ab28aef3 compose: recreate container when mounted image digest changes
Until now, mustRecreate logic only checked for divergence in TypeVolume
mounts but ignored TypeImage mounts. This inconsistency caused containers
to erroneously retain stale images even after the source image was rebuilt.
This commit updates ensureImagesExists to resolve image volume sources to
their digests using the official reference package. This enables ServiceHash
(config hash) to naturally detect underlying image digest changes,
triggering recreation via the standard convergence logic.
An E2E test case is added to verify this behavior.
Fixes #13547

Signed-off-by: ibrahim yapar <[email protected]>
2026-01-26 15:55:44 +01:00