Skip to content

fix(start): give a started use_api_socket service its config file - #14393

Merged
ndeloof merged 3 commits into
docker:mainfrom
ndeloof:fix/start-use-api-socket
Oct 26, 2026
Merged

ndeloof merged 3 commits into
docker:mainfrom
ndeloof:fix/start-use-api-socket

Conversation

@ndeloof

@ndeloof ndeloof commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

What this PR does, in one sentence

compose start now gives a use_api_socket service the config file the option promises, when its container was created beforehand.

Context

A service with use_api_socket: true is meant to find a Docker client configuration at /run/secrets/docker/config.json, with DOCKER_CONFIG pointing there (#14386). up -d and the foreground up provide it since #14290 and #14305. What was left is a container that is created first and started later: create then start, up --no-start then start, or start <service> for a dependency. It came up with DOCKER_CONFIG set and nothing at that path.

The option works by rewriting the project (a #apisocket config, the socket bind and the environment variable), and the file is injected when a container starts, from the service the start plan carries. create and run applied the rewriting, start did not: the environment variable was set at creation, the file never injected.

What the PR brings

start applies the rewriting like create and run do, on the copy of the project it already makes, so the caller's project is left alone. A project that was already rewritten, such as the one run hands to the dependencies it starts, is not rewritten twice. The rewriting also tolerates a project without a service environment or without a configs map, which is what compose start loads (it resolves no environment): the first version of this fix panicked there, and an end-to-end scenario caught it.

Nothing changes for a project that does not use the option. Worth knowing:

  • compose start now looks up the credentials for a project that uses the option, as create, up and run already do, even when everything is already running.
  • A read_only: true service using the option fails compose start with the error up -d already gives it: the file cannot be created in a read-only service.
  • compose -p <name> start without a compose file rebuilds the services from the container labels, which do not carry the option: the file is still missing in that mode.
  • compose restart of a container that was never started injects no configs or secrets at all, this one included. It predates this change and is a separate matter.

Fixes #14386.

🤖 Generated with Claude Code

A container created beforehand and only started by `compose start`
(`create` then `start`, `up --no-start` then `start`, or a dependency named
to `start`) came up with DOCKER_CONFIG pointing at /run/secrets/docker and no
file there: use_api_socket is applied by rewriting the project, and the
config file it adds is injected when a container starts, from the project the
start works on. Create and run applied the rewriting, start did not.

start() now applies it too, on the copy it already makes of the project, so
the caller's is left alone, and a project already rewritten (a dependency
started by run) is not rewritten twice. The rewriting tolerates a project
without environment or configs maps, as the one `compose start` loads.

up -d, a foreground up, scale and run already provided the file.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
…_socket writes into

The project `compose start` loads has no environment nor configs map, which
the rewriting used to write into; a project built with empty maps is the
other shape. Both are started with the config file in place, and neither
caller's project is written to.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
…e comments

- a project that already went through use_api_socket, as the one `run` hands
  to the dependencies it starts, is injected once by start(): rewriting it
  again would duplicate the config entry, and the file would be copied twice.
  The first test also checks that the option was applied;
- the comments say which maps the rewriting may find nil: the service
  Environment in the project `compose start` loads, the Configs of a
  programmatic one, and that a project rebuilt from the labels knows nothing of
  the option.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@ndeloof
ndeloof requested review from a team as code owners October 26, 2026 16:00

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/compose/start.go 33.33% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@ndeloof
ndeloof merged commit 86e504c into docker:main Oct 26, 2026
64 of 66 checks passed
@ndeloof
ndeloof deleted the fix/start-use-api-socket branch October 26, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] use_api_socket no longer injects credentials file since v5.5.1

3 participants