-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[BUG] secrets from environment not resolved on included projects #11952
Copy link
Copy link
Closed
compose-spec/compose-go
#655Labels
Description
Description
I'm trying to include a compose file into my main compose which contains a secret defined on it's own environment file, but compose fails to resolve it.
The main compose includes a child compose which has a secret loaded on it's own .env file.
When moving app/.env to .env it works fine, which means include is not respecting project_directory nor env_file for the secret resolving.
Is there any way I can avoid this besides copying the .env to the root or adding the --env-file app/.env flag to the docker compose up command? (which also works)
Steps To Reproduce
The project structure is as follows:
├── app
│ └── .env
│ └── docker-compose.yml
└── docker-compose.yml
docker-compose.yml
---
include:
- path: app/docker-compose.yml
project_directory: app
env_file: app/.env
services:
main:
image: nginx:1.25.4-alpineapp/docker-compose.yml
---
services:
app:
image: nginx:1.25.4-alpine
secrets:
- passwd
secrets:
passwd:
environment: PASSWDapp/.env
PASSWD=secret
When trying to run the previous stack, I get the following error:
$ docker compose up
[+] Running 1/3
✔ Network demo_default Created 0.1s
⠋ Container demo-app-1 Creating 0.1s
⠋ Container demo-main-1 Creating 0.1s
environment variable "PASSWD" required by file "demo_passwd" is not setCompose Version
Docker Compose version v2.28.1
Docker Environment
Client: Docker Engine - Community
Version: 27.0.1
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
Reactions are currently unavailable