-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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] unexpected character "-" in variable name since v2.29.3 #12123
Comments
While technically Linux can use env-vars with hyphens as name (any character except What I suspect happened here is that the libary used by compose possibly considers them as invalid formatted substitution character, and the part after the hyphen as That said, |
This looks related to this PR; However the docker run --rm --env "hello-world=hello-value" alpine printenv hello-world
hello-value For reference; this is the validation in the OCI runtime (runc); https://github.com/opencontainers/runc/blob/7c2e69f1c4a7df1cf4690ccfc68c0a3857251d12/libcontainer/init_linux.go#L258-L281 // populateProcessEnvironment loads the provided environment variables into the
// current processes's environment.
func populateProcessEnvironment(env []string) error {
for _, pair := range env {
p := strings.SplitN(pair, "=", 2)
if len(p) < 2 {
return errors.New("invalid environment variable: missing '='")
}
name, val := p[0], p[1]
if name == "" {
return errors.New("invalid environment variable: name cannot be empty")
}
if strings.IndexByte(name, 0) >= 0 {
return fmt.Errorf("invalid environment variable %q: name contains nul byte (\\x00)", name)
}
if strings.IndexByte(val, 0) >= 0 {
return fmt.Errorf("invalid environment variable %q: value contains nul byte (\\x00)", name)
}
if err := os.Setenv(name, val); err != nil {
return err
}
}
return nil
} |
env-file when used in compose does support interpolation (and a bunch of our users rely on this feature) |
Right, but the reverse also looks to be true; it's rejecting env-vars that should be considered valid 🤔 |
So |
Yeah, I recall we once added validation for environment-variables, but then had to revert, for similar reasons; |
When will the fix be published? I’ve tested docker compose |
It seems to work now with docker compose |
fix took place in compose-go library |
I'm still facing this issue, compose version is 2.29.7, is there something else I should update? |
character |
I'm confused, I thought earlier comments said this was fixed, it's been working before the update. |
yes, we tried to propose a fix for this issue, but this triggered more issues as variables with a |
For those affected by this issue: A possible workaround is to remove the respective variables from the .env file and instead apply them via the "environment"
|
Is it correct to say that it was fixed by compose-spec/compose-go#683 (released in v2.30.0)? |
I just upgraded to Docker Compose 2.31.0, and it works. |
Can confirm upgrading Docker Compose solves this. (docker-compose-plugin 2.32.1-1 |
Description
Environment variables defined via an env_file that have "-" characters in their name get refused after updating docker-compose from
v2.29.2
tov2.29.3
Steps To Reproduce
myenv.env
foo-bar=test
Expected behaviour (
v2.29.2
)Actual behaviour (
v2.29.3
)Compose Version
Docker Environment
Anything else?
No response
The text was updated successfully, but these errors were encountered: