Skip to content

Add secrets/configs driver: copy, for use with a remote Docker host - #14189

Closed
NAVEENKUMARKR777 wants to merge 1 commit into
docker:mainfrom
NAVEENKUMARKR777:11867-remote-host-secrets-configs-copy
Closed

Add secrets/configs driver: copy, for use with a remote Docker host#14189
NAVEENKUMARKR777 wants to merge 1 commit into
docker:mainfrom
NAVEENKUMARKR777:11867-remote-host-secrets-configs-copy

Conversation

@NAVEENKUMARKR777

Copy link
Copy Markdown

Summary

This has been open since May 2024 with 50+ comments and three separate community PRs (#11871/#12251 by @andoks, #11984/#12448 by @schaubl, and the narrower #12625) all closed without merging. The problem: secrets.<name>.file/configs.<name>.file are interpreted as a path on the Docker host, so Compose bind-mounts it into the container — which breaks entirely once DOCKER_HOST/a docker context points at a remote engine, since Compose is a client-side tool and cannot bind-mount a path that only exists on the client.

Every prior attempt switched the behavior unconditionally based on file: being set, and was rejected for the same reason each time. From @ndeloof's review on #12448:

This PR doesn't address comments on #11867 tl;dr: config/secret file MAY be mounted from (remote) docker host. Many users rely on this, some do even require changes to the original file to be propagated inside container. So we can't just switch to a distinct behavior which would introduce a breaking change. This would at least require an explicit opt-in flag in compose.yaml

This PR adds exactly that: driver: copy as an explicit opt-in.

secrets:
  db_password:
    file: ./db_password.txt
    driver: copy

When set, the file is read from the client's local filesystem and copied into the container once, at creation — reusing the content-injection path Compose already has for content:-based secrets/configs (copyFileToContainer/createTar) — instead of bind-mounted. Without driver: copy, behavior is completely unchanged: existing users who rely on the bind mount (editing the file on the Docker host directly, or watch-driven sync) are unaffected. Any other driver value is still rejected, as before.

New doc page: docs/secrets-and-configs-driver-copy.md.

Test plan

  • go test ./pkg/compose/... — new unit tests for resolveFileContent's copy-driver path and precedence (Content/Environment still win), and for the bind-mount-skip/validation logic in buildContainerSecretMounts/buildContainerConfigMounts
  • golangci-lint run --build-tags e2e ./... — 0 issues
  • New e2e scenario (TestSecretCopyDriver) added but not run in this environment — no Docker daemon available. It specifically verifies the copy is a one-time snapshot (editing the client's file after up does not reach the running container), the key behavioral difference from a bind mount. Please run go test -tags e2e ./pkg/e2e/ -run TestSecretCopyDriver before merging.

Closes #11867

🤖 Generated with Claude Code

secrets.<name>.file and configs.<name>.file are interpreted as a path on
the Docker host: Compose bind-mounts that host path into the container.
This breaks entirely once DOCKER_HOST or a docker context points at a
remote engine, since Compose is a client-side tool and cannot bind-mount a
path that only exists on the client's machine into a remote container.

This has been open since 2024 with three separate community PRs
(docker#11871/docker#12251, docker#11984/docker#12448, docker#12625) rejected for the same reason: they
switched the behavior unconditionally based on `file:` being set, which
the maintainer flagged as a breaking change for users who rely on the
existing bind mount (editing the file on the Docker host directly, or
`watch`-driven sync) - see the review comment on docker#12448.

Add driver: copy as the explicit opt-in the maintainer asked for: when
set, the secret/config's file is read from the CLIENT's local filesystem
and copied into the container (reusing the existing content-injection
path already used for `content:`), instead of bind-mounted. Without
driver: copy, behavior is completely unchanged. Any other driver value is
still rejected, as before.

Closes docker#11867

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Naveenkumar <naveenkumarkr555@gmail.com>
@glours

glours commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

This account has been blocked after review: it opened a burst of near-identical, AI-generated PRs across many unrelated projects in a very short window, without real review or testing behind them, not a comment on AI-assisted contributions in general, which are welcome here when disclosed and reviewed.

@glours glours closed this Sep 7, 2026
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.

Support remote DOCKER_HOST by copying configs and secrets files instead of bind mounting them

2 participants