compose icon indicating copy to clipboard operation
compose copied to clipboard

Filter out empty DNS entries

Open IvanRibakov opened this issue 1 year ago • 3 comments

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.

IvanRibakov avatar Apr 05 '24 11:04 IvanRibakov

Same problem here

enmanuelmoreira avatar Apr 07 '24 21:04 enmanuelmoreira