You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
About two months ago I discovered a bug in Docker Compose when I wanted to use required environment variables. Everything works as expected when I have only one variable, but when I have multiple variables in a string, only the last one is validated. It is more complex, because it is actually validated and the error message is just overridden by the next non-empty variable.
However it was not merged and now the latest development version of "compose-spec/compose-go" is not compatible with Docker Compose. I don't exactly know the relation between the compose and compose-go developer teams, so I don't know what the next step could be, but I would like Docker Compose v2 to work properly so I offer any help I can give you. In the end, people will see and remember bugs in Docker Compose and not in its modules.
I create this issue because even if my pull request were merged, considering the current branches and the process of the development, you could not apply that in Docker Compose until you make Docker Compose compatible with the new changes in compose-go in which ExtraHosts is not []string anymore but type HostsList map[string]string . You might have a better idea how it could be fixed in Compose v2 as well without waiting for an other minor version or you can assure us that a new minor version with that fix could be released soon.
If I can see that bugfixes like these can happen, I am happy to continue to work on other bugs as well if it helps.
Steps to reproduce the issue:
Use a compose file like this:
services:
bash:
image: bash:5.1command:
- bash
- -c
- "echo VARIABLES: ${COMPOSE_TEST_A:?A is empty} ${COMPOSE_TEST_B:?B is empty} ${COMPOSE_TEST_C:?C is empty}"
docker compose up
COMPOSE_TEST_B="" docker compose up
COMPOSE_TEST_C="" docker compose up
Describe the results you received:
The output of the above example is:
[+] Running 1/0
⠿ Container compose-test-bash-1 Recreated 0.0s
Attaching to compose-test-bash-1
compose-test-bash-1 | VARIABLES: A B C
compose-test-bash-1 exited with code 0
[+] Running 1/0
⠿ Container compose-test-bash-1 Created 0.0s
Attaching to compose-test-bash-1
compose-test-bash-1 | VARIABLES: A C
compose-test-bash-1 exited with code 0
invalid interpolation format for services.bash.command.[]: "required variable COMPOSE_TEST_C is missing a value: C is empty". You may need to escape any $ with another $
Describe the results you expected:
Any empty but required variable should result an error message started with the first error:
[+] Running 1/0
⠿ Container compose-test-bash-1 Recreated 0.0s
Attaching to compose-test-bash-1
compose-test-bash-1 | VARIABLES: A B C
compose-test-bash-1 exited with code 0
invalid interpolation format for services.bash.command.[]: "required variable COMPOSE_TEST_B is missing a value: B is empty". You may need to escape any $ with another $
invalid interpolation format for services.bash.command.[]: "required variable COMPOSE_TEST_C is missing a value: C is empty". You may need to escape any $ with another $
The environment is not relevant here since I already found the cause which was error messages overriding each other in a callback function, however I tried on MacOs and Linux mainly.
The text was updated successfully, but these errors were encountered:
Description
About two months ago I discovered a bug in Docker Compose when I wanted to use required environment variables. Everything works as expected when I have only one variable, but when I have multiple variables in a string, only the last one is validated. It is more complex, because it is actually validated and the error message is just overridden by the next non-empty variable.
I also fixed it in "compose-spec/compose-go": compose-spec/compose-go#242
However it was not merged and now the latest development version of "compose-spec/compose-go" is not compatible with Docker Compose. I don't exactly know the relation between the compose and compose-go developer teams, so I don't know what the next step could be, but I would like Docker Compose v2 to work properly so I offer any help I can give you. In the end, people will see and remember bugs in Docker Compose and not in its modules.
I create this issue because even if my pull request were merged, considering the current branches and the process of the development, you could not apply that in Docker Compose until you make Docker Compose compatible with the new changes in compose-go in which ExtraHosts is not
[]string
anymore buttype HostsList map[string]string
. You might have a better idea how it could be fixed in Compose v2 as well without waiting for an other minor version or you can assure us that a new minor version with that fix could be released soon.If I can see that bugfixes like these can happen, I am happy to continue to work on other bugs as well if it helps.
Steps to reproduce the issue:
Use a compose file like this:
with this .env file:
Run
Describe the results you received:
The output of the above example is:
Describe the results you expected:
Any empty but required variable should result an error message started with the first error:
Output of
docker info
:Additional environment details:
The environment is not relevant here since I already found the cause which was error messages overriding each other in a callback function, however I tried on MacOs and Linux mainly.
The text was updated successfully, but these errors were encountered: