Skip to content

fix: surface Docker connection errors before project load - #13972

Open
scarab-systems wants to merge 2 commits into
docker:mainfrom
scarab-systems:13649-preserve-docker-socket-error
Open

fix: surface Docker connection errors before project load#13972
scarab-systems wants to merge 2 commits into
docker:mainfrom
scarab-systems:13649-preserve-docker-socket-error

Conversation

@scarab-systems

@scarab-systems scarab-systems commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

What I did

Make docker compose up check Docker API reachability after local flag validation and before project loading. This keeps socket permission or connection errors from being hidden by later config path fallback errors such as is a directory.

Moved the --attach / --attach-dependencies conflict into local flag validation so it is still reported before any Docker API call.

Added regression tests for the empty COMPOSE_FILE fallback path with a mocked Docker API connection error, and for the attach flag conflict being validated before Docker client use.

Related issue

Fixes #13649

Testing

  • gofmt -s -w cmd/compose/up.go cmd/compose/compose_test.go
  • go test ./cmd/compose -run 'TestUp(ReturnsDockerConnectionErrorBeforeConfigPathFallback|ValidatesFlagConflictsBeforeDockerConnection)' -count=1
  • go test ./cmd/compose ./pkg/compose -count=1
  • make test
  • Manual smoke with COMPOSE_FILE="" and an inaccessible Docker socket path: surfaced the Docker API connection error instead of is a directory
  • make build-and-e2e attempted locally; plugin-mode e2e failed on TestImageVolume, TestImageVolumeRecreateOnRebuild, and TestComposeModel. The same three failures reproduce on unmodified origin/main in this local environment.

Signed-off-by: ScarabSystems <scarab.systems@yahoo.com>
Comment thread cmd/compose/up.go
if err := validateFlags(&up, &create); err != nil {
return err
}
return checkDockerConnection(ctx, dockerCli)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wonder if this should be inside runUp to avoid connecting to the API before all other validation is completed (at least at a glance it feels like a more natural place to validate the connection)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I checked this against the command path after your note. runUp is reached after the project has already been loaded by p.WithServices(...); the misleading is a directory error from #13649 is raised during that earlier project-loading path, so moving the ping into runUp would leave the reported case unchanged.

I kept the reachability check after local validation but before project loading, and moved the remaining --attach / --attach-dependencies conflict into validateFlags so that flag-only validation still wins before any Docker API call. Added coverage for both paths. If there is another pre-load owner you prefer for the connection check, I can adjust the placement.

Move the --attach/--attach-dependencies conflict into validateFlags so local flag validation still completes before the Docker API reachability check added for docker#13649.

Add a regression test that exercises the conflict without expecting a Docker client call.

Verification:

- go test ./cmd/compose -run 'TestUp(ReturnsDockerConnectionErrorBeforeConfigPathFallback|ValidatesFlagConflictsBeforeDockerConnection)' -count=1

- go test ./cmd/compose ./pkg/compose -count=1

- make test

- make build-and-e2e (fails on base-reproduced e2e tests: TestImageVolume, TestImageVolumeRecreateOnRebuild, TestComposeModel)

Signed-off-by: ScarabSystems <scarab.systems@yahoo.com>
@scarab-systems
scarab-systems marked this pull request as ready for review July 26, 2026 21:42
@scarab-systems
scarab-systems requested review from a team as code owners July 26, 2026 21:42
@scarab-systems
scarab-systems requested review from glours and ndeloof July 26, 2026 21:42
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] Misleading error message if user has no permission for docker socket

2 participants