Filter out empty DNS entries
Description
Previously this DockerCompose configuration would successfully start a container:
# ANOTHER_SERVICE_IP is not set and defaults to blank string
dns: ${ANOTHER_SERVICE_IP}
But using latest Docker+DockerCompose on Linux
Docker version 26.0.0, build 2ae903e
Docker Compose version v2.25.0
container fails to start:
WARN[0000] The "ANOTHER_SERVICE_IP" variable is not set. Defaulting to a blank string.
Error response from daemon: bad nameserver address : ParseAddr(""): unable to parse IP
https://github.com/moby/moby/blob/d25b0bd7ea6ce17ca085c54d5965eeeb66417e52/libnetwork/sandbox_dns_unix.go#L259-L269
I can see how it makes sense from Docker perspective to be strict about supplied configuration options. I'm wondering whether it would be possible for the DockerCompose to filter out empty DNS entries before passing them to Docker and logging a warning. As far as I understand there is no other way to have a conditional behaviour that either uses external DNS service or the default host one without creating 2 different service configurations.
Same problem here