compose icon indicating copy to clipboard operation
compose copied to clipboard

Strip empty DNS entries to avoid Moby parse errors when creating sandbox DNS

Open IvanRibakov opened this issue 1 year ago • 2 comments

What I did

Ensured that each service's DNS settings are stripped from empty entries that could result from using ENV variables that defaulted to blank strings.

For example:

  service:
    # ANOTHER_SERVICE_IP is not set and defaults to blank string
    dns: ${ANOTHER_SERVICE_IP}
    ...

Related issue https://github.com/docker/compose/issues/11690

IvanRibakov avatar Apr 05 '24 15:04 IvanRibakov

Is there anything I could do to help move this PR forward?

IvanRibakov avatar Apr 26 '24 08:04 IvanRibakov

Implementation is correct but IMHO this issue will apply to way more places, not just dns. We miss a way to mark an entry in compose.yaml as "to be ignored if value is empty". I wonder it would be better we introduce a global mechanism for this purpose, maybe comparable to !override:

 service:
    # ANOTHER_SERVICE_IP is not set and defaults to blank string
    dns: !omitempty ${ANOTHER_SERVICE_IP} 
    ...

ndeloof avatar May 22 '24 10:05 ndeloof