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

[BUG] Secrets not loading from .env file #11941

Open
ollipa opened this issue Jun 27, 2024 · 1 comment
Open

[BUG] Secrets not loading from .env file #11941

ollipa opened this issue Jun 27, 2024 · 1 comment

Comments

@ollipa
Copy link

ollipa commented Jun 27, 2024

Description

Previously in version v2.27.1 this worked:

In .env:

MY_SECRET=very_secret

In docker compose yaml:

secrets:
  MY_SECRET:
    environment: MY_SECRET

However in after updating to v2.28.1 the secret is not loaded correctly from .env file anymore causing builds that rely on the secret to fail.

Steps To Reproduce

Define a secret in .env file and try to use it in docker compose.

Compose Version

Docker Compose version v2.28.1

Docker Environment

Client: Docker Engine - Community                                               
 Version:    27.0.2                                                             
 Context:    default                                                            
 Debug Mode: false                                                              
 Plugins:                                                                       
  buildx: Docker Buildx (Docker Inc.)                                           
    Version:  v0.15.1                                                           
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx                     
  compose: Docker Compose (Docker Inc.)                                         
    Version:  v2.28.1                                                           
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Anything else?

No response

@ndeloof
Copy link
Contributor

ndeloof commented Jun 28, 2024

.env defines variables to be used for interpolation, not os.Environment. This used to be set as os.Env due to a design issue in earlier versions. I suggest you source this .env file to populate os.Env before you run compose.
We could introduce an explicit content attribute for secrets so that one can write:

secrets:
  MY_SECRET:
    content: ${MY_SECRET}

doing so, variables interpolation from .env would set secret value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants