<p>We have not been able to figure out what the problem is or what a solution could be.</p>

<p>The workaround is actually not using the <code>10.0.2.0</code> subnet, so I will add that as an answer as requested in the comments.</p>

<p>If someone finds the real issue and solution here, I will gladly accept that answer though.</p>

CC BY-SA 4.0
2020-01-03T22:47:00.703Z
2020-01-03T22:47:00.703Z
Worp
<p>The ultimate problem I am facing is this:</p>

<pre><code>[root@527eb70c04c9 my-service]# ping google.com
ping: google.com: Name or service not known
</code></pre>

<p>Inside my container, I can't resolve public domains, although the network is defined as not internal:</p>

<pre><code>networks:
  my-service-network:
    driver: overlay
    internal: false
    attachable: true
    ipam:
      driver: default
      config:
        - subnet: 10.0.2.0/24
</code></pre>

<p>As soon as I change my subnet from 10.0.2.0 to 10.0.5.0 (really just "NOT" have it be 10.0.2.0) everything works:</p>

<pre><code>networks:
  ess-team-service:
    driver: overlay
    internal: false
    attachable: true
    labels:
      - "group=ess-services"
    ipam:
      driver: default
      config:
      - subnet: 10.0.5.0/24

ping google.com
PING google.com (172.217.22.14) 56(84) bytes of data.
64 bytes from fra16s14-in-f14.1e100.net (172.217.22.14): icmp_seq=1 ttl=61 time=25.0 ms
64 bytes from fra16s14-in-f14.1e100.net (172.217.22.14): icmp_seq=2 ttl=61 time=22.7 ms
64 bytes from fra16s14-in-f14.1e100.net (172.217.22.14): icmp_seq=3 ttl=61 time=22.5 ms
^C
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 22.575/23.462/25.083/1.161 ms
</code></pre>

<p>A colleague referred to the problem as being caused because Docker's own nameserver is on 10.0.2.0 but I can't find information to back this theory up let alone confirm it.</p>

<p>The main problem is: Sometimes it works. Most times it doesn't but sometimes I can ping google inside the container while the subnet IS 10.0.2.0</p>

CC BY-SA 4.0
2019-01-31T06:18:35.307Z
Might it have to do with dns masquerade mentioned here: https://docs.docker.com/install/linux/linux-postinstall/#dns-resolver-found-in-resolvconf-and-containers-cant-use-it ?
Worp
CC BY-SA 4.0
2020-01-06T06:51:38.983Z
Thanks for posting an answer +1
030
<docker><docker-swarm><dns>
Docker Containers fails to DNS resolve on subnet 10.0.2.0/24
Worp
# Docker Containers fails to DNS resolve on subnet 10.0.2.0/24

(Asked by: username_0 on 2019-01-29)

The ultimate problem I am facing is this:
[root@527eb70c04c9 my-service]# ping google.com
ping: google.com: Name or service not known

Inside my container, I can't resolve public domains, although the network is defined as not internal:
networks:
  my-service-network:
    driver: overlay
    internal: false
    attachable: true
    ipam:
      driver: default
      config:
        - subnet: 10.0.2.0/24

As soon as I change my subnet from 10.0.2.0 to 10.0.5.0 (really just "NOT" have it be 10.0.2.0) everything works:
networks:
  ess-team-service:
    driver: overlay
    internal: false
    attachable: true
    labels:
      - "group=ess-services"
    ipam:
      driver: default
      config:
      - subnet: 10.0.5.0/24

ping google.com
PING google.com (172.217.22.14) 56(84) bytes of data.
64 bytes from fra16s14-in-f14.1e100.net (172.217.22.14): icmp_seq=1 ttl=61 time=25.0 ms
64 bytes from fra16s14-in-f14.1e100.net (172.217.22.14): icmp_seq=2 ttl=61 time=22.7 ms
64 bytes from fra16s14-in-f14.1e100.net (172.217.22.14): icmp_seq=3 ttl=61 time=22.5 ms
^C
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 22.575/23.462/25.083/1.161 ms

A colleague referred to the problem as being caused because Docker's own nameserver is on 10.0.2.0 but I can't find information to back this theory up let alone confirm it.
The main problem is: Sometimes it works. Most times it doesn't but sometimes I can ping google inside the container while the subnet IS 10.0.2.0

**Tags:** docker, docker-swarm, dns

> **Comments:**
> **username_0**: Might it have to do with dns masquerade mentioned here: https://docs.docker.com/install/linux/linux-postinstall/#dns-resolver-found-in-resolvconf-and-containers-cant-use-it ?  
> **username_1**: Thanks for posting an answer +1  

---

## 1 answers

### Answer by username_0 on 2020-01-03. Score: 1 | Accepted answer

We have not been able to figure out what the problem is or what a solution could be.

The workaround is actually not using the `10.0.2.0` subnet, so I will add that as an answer as requested in the comments.

If someone finds the real issue and solution here, I will gladly accept that answer though.


---

