Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update config/secret handling: Copy files into containers instead of bind mounting #12448

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

schaubl
Copy link

@schaubl schaubl commented Jan 9, 2025

Currently, Docker Compose copies a config or secret into the container if the source is an environment variable or inlined content. However, if the source is a file, the file is bind mounted into the container. This approach fails when Docker Compose is invoked on a different filesystem than the Docker daemon host filesystem (e.g., when called from within a container or remotely using the -H option).

This PR changes the behavior for file-based config/secret sources to match the handling of environment variables and inlined content. Specifically, it reads the file from the filesystem where Docker Compose is executed (like Docker Stack) and copies it into the container.

This update enhances the functionality of Docker Compose when run "remotely," providing the ability to push configuration files, a feature previously available only with Docker Stack/Swarm.

What I did:

  • Updated the behavior for handling configs and secrets sourced from files.
  • Ensured consistency with the documentation and the behavior of Docker Stack.
  • Enabled Docker Compose to push configuration files when run remotely, aligning with Docker Stack/Swarm capabilities.

Notes:

  1. It fixes Support remote DOCKER_HOST by copying configs and secrets files instead of bind mounting them #11867
  2. It is a reopening of Update config/secret handling: Copy files into containers instead of bind mounting #11984 based on the latest code base
  3. It is an alternative to Add support for configs.file's and secrets.file's on remote docker hosts #12251
    Differences it that this PR checks the validity of the config/secret parameters in getCreateConfigs before the container is created where the other one does it after.
    Also this PR doesn't support directories which correspond to the doc and the behaviour of Docker Configs&Secrets used by Swarm/Stack.

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
1 participant