environment FOO with no value nor equal sign means "propagate value from user's environment, or unset variable"
So, as we resolve environment, empty value with no matching entry in user's environment MUST not result into removing entry from service definition.
Build args do not follow this rule. --build-arg FOO will propagate user's environment value, but if not set build arg will keep using value set by Dockerfile
environment
FOO
with no value nor equal sign means "propagate value from user's environment, or unset variable" So, as we resolve environment, empty value with no matching entry in user's environment MUST not result into removing entry from service definition. Build args do not follow this rule.--build-arg FOO
will propagate user's environment value, but if not set build arg will keep using value set by Dockerfilefixes https://github.com/docker/compose/issues/11962 supersede https://github.com/compose-spec/compose-go/pull/634 see https://github.com/docker/compose/pull/11965