docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
33.83k stars 5.21k forks source link

Filter out empty DNS entries #11690

Open IvanRibakov opened 6 months ago

IvanRibakov commented 6 months ago

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.

enmanuelmoreira commented 6 months ago

Same problem here

jhrotko commented 3 days ago

@IvanRibakov Could you provide an example?

IvanRibakov commented 3 days ago

I went as far as to provide a pull request which unfortunately was rejected. @jhrotko what exactly are you looking for from the example that is missing from the current issue description?