This can be resolved by providing the docker plugin configuration with your DNS server address. Note that the example below uses dummy IP addresses; please replace with your actual IP addresses.
pipeline:
docker:
image: plugins/docker
custom_dns: [ 10.10.0.1, 10.10.0.2 ]
If you are using the enterprise edition you can configure the following global environment variable:
- name: PLUGIN_CUSTOM_DNS
value: 10.10.0.1,10.10.0.2
Why is this necessary?
Why does this issue surface for some configurations and not others? And in these instances, why does the DNS configuration not propagate to Docker in Docker? And why does this work with the default bridge but not user-defined networks? Unfortunately I cannot provide the root cause at this time, but can provide some information that might explain the behavior ...
It seems the logic for configuring DNS could be different depending on your version of Docker, Host Machine configuration, etc.
The exact details of how Docker manages the DNS configurations inside the container can change from one Docker version to the next. So you should not assume the way the files such as /etc/hosts, /etc/resolv.conf are managed inside the containers and leave the files alone and use the following Docker options instead.
It also seems the default bridge network does behave different than user-defined bridge networks by design:
In order to maintain backward compatibility, the DNS configuration in default bridge network is retained with no behavioral change. Please refer to the DNS in default bridge network for more information on DNS configuration in the default bridge network.
I wish I could provide a detailed technical root cause for this issue, and hope that someone can fill in the blanks for this answer. In the meantime, please use the workaround documented above.