# Docker: Custom Networks - Domain Name Resolution with Gateway

**URL:** <https://forum.inductiveautomation.com/t/docker-custom-networks-domain-name-resolution-with-gateway/99636>\
**Category:** Ignition\
**Created:** [December 10, 2024, 3:54pm UTC](https://forum.inductiveautomation.com/t/docker-custom-networks-domain-name-resolution-with-gateway/99636 "2024-12-10T15:54:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mudbay](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@mudbay](https://forum.inductiveautomation.com/u/mudbay)\
**Post date:** [December 10, 2024, 3:54pm UTC](https://forum.inductiveautomation.com/t/docker-custom-networks-domain-name-resolution-with-gateway/99636/1 "2024-12-10T15:54:34Z")

</div>

I may be showing my lack of knowledge with this question, but can you use Docker Custom Network Container names in URLs within a Gateway? Example would be using the Container Name in a URL for MQTT Transmission.

My experiments so far indicate that only the static IP address can be used to another container and not the Custom Network name even though within the containers Bash session the Custom Network name does resolve with a 'ping' command using the name (i.e. Container resolves name, but Gateway does not).

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [December 10, 2024, 5:54pm UTC](https://forum.inductiveautomation.com/t/docker-custom-networks-domain-name-resolution-with-gateway/99636/2 "2024-12-10T17:54:47Z")

</div>

You definitely can do this. Keep in mind that the default `bridge` network on a standard Docker Engine installation does **NOT** provide DNS records for other attached containers. But on other custom networks you'll be able to resolve by container name (or in the case of Docker Compose, "service" name).

![forum-99636](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/0/e089f65f018c8116965fe453064425ce100e598e.gif)

ref: [Differences between user-defined bridges and the default bridge](https://docs.docker.com/engine/network/drivers/bridge/#differences-between-user-defined-bridges-and-the-default-bridge)

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [December 10, 2024, 6:11pm UTC](https://forum.inductiveautomation.com/t/docker-custom-networks-domain-name-resolution-with-gateway/99636/3 "2024-12-10T18:11:52Z")

</div>

> [@mudbay](#):
>
> My experiments so far indicate that only the static IP address can be used to another container and not the Custom Network name even though within the containers Bash session the Custom Network name does resolve with a 'ping' command using the name (i.e. Container resolves name, but Gateway does not).

I realize that I showed an example with a `ping` command, but it can also be used in other places where a hostname can be supplied, such as in the URL for MQTT Engine/Transmission, e.g.:

 ![SCR-20241210-kzpz](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/8/a83700a8df316fff7972792c5d0918276e8828aa.png)

---

<div class="post-metadata">

**Author:** ![mudbay](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@mudbay](https://forum.inductiveautomation.com/u/mudbay)\
**Post date:** [December 12, 2024, 11:51pm UTC](https://forum.inductiveautomation.com/t/docker-custom-networks-domain-name-resolution-with-gateway/99636/4 "2024-12-12T23:51:09Z")

</div>

Thanks Kevin for the response. I see your example, but when I try to use this with a Custom Network it oddly does not resolve in the MQTT URL all though it does resolve in the container's BASH session (see: GIF)

Snippet of Docker-compose that creates the custom network:  
networks:  
iX\_Sandbox:  
driver: bridge  
ipam:  
config:  
- subnet: 192.168.1.0/24

![CustomNetworksAndMQTT](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/7/47cfa3f69bd07ee5ecfdc0804b604ec546f771f5.gif)

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [December 16, 2024, 4:10pm UTC](https://forum.inductiveautomation.com/t/docker-custom-networks-domain-name-resolution-with-gateway/99636/5 "2024-12-16T16:10:39Z")

</div>

> iX\_Sandbox

I bet that this is the problem. Underscore characters `_` are not recommended in URLs. I've had issues in the past here...

EDIT: Revised reasoning is that underscore characters are _invalid_ in hostnames, thus not recommended in URLs.

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [December 16, 2024, 4:22pm UTC](https://forum.inductiveautomation.com/t/docker-custom-networks-domain-name-resolution-with-gateway/99636/6 "2024-12-16T16:22:22Z")

</div>

Confirmed. When I setup two containers `ignition_1` and `ignition_2`, I get this error from MQTT Engine trying to use `ignition_1` in the URL:

 ![SCR-20241216-jlfp](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/a/5a1fb3bf83678a00792e00dafde9deb4a64f0976.png)

> `ME-d681d05b-f2fb-4dca: Error while attempting connect (with autoReconnect=false) to tcp://ignition_1:1883: Unable to make field private transient java.lang.String java.net.URI.userInfo accessible: module java.base does not "opens java.net" to unnamed module @299ee532`

Following this...

```python
# Disconnect `ignition_1` container from `testing` bridge network
docker network disconnect testing ignition_1
# Reconnect `ignition_1` container to `testing` network with alias `ignition-1`
docker network connect --alias ignition-1 testing ignition_1

```

... and adjusting the URL to use `ignition-1` got me a valid connection:

 ![SCR-20241216-jmnr](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/6/a6b3549a4b7778b104ed93a781d71c5de627a46d.png)

So you can either adjust your service name, or make sure to add the proper alias to the service definition. ref: [Compose service aliases](https://github.com/compose-spec/compose-spec/blob/main/05-services.md#aliases)

---

<div class="post-metadata">

**Author:** ![mudbay](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@mudbay](https://forum.inductiveautomation.com/u/mudbay)\
**Post date:** [December 16, 2024, 8:40pm UTC](https://forum.inductiveautomation.com/t/docker-custom-networks-domain-name-resolution-with-gateway/99636/7 "2024-12-16T20:40:53Z")

</div>

Thanks Kevin for the "CSI" work on that. You are right and I should have known that with URLs as I have experienced that before.

Thanks again.
