How to set DNS-server and/or hosts file in docker #1332

Closed
opened 2026-02-28 02:17:42 -05:00 by deekerman · 6 comments
Owner

Originally created by @HolgerAusB on GitHub (Aug 13, 2022).

⚠️ Please verify that this bug has NOT been raised before.

  • I checked and didn't find similar issue

🛡️ Security Policy

📝 Describe your problem

I am quite new to docker and kuma. I tried to monitor a local https server by name https://sub1.example.com:1234 and it lasts me hours until I realized that kuma never got an ip of that server. The Raspi got its addresses from pihole, which would deliver back a local IP for that host name. But as kuma is in a container, there is a different dns server setting in the container which asks a dns server outside the local net. But as my https-server sub1 is not reachable from the internet, the check fails.

So, is it possible somehow to set the dns server setting inside the docker container (or as new feature in kuma)? And/or is there a way to set a hosts file with static name>ip ?

Meanwhile I set the monitor to https://192.168.1.23:1234 and ckecked 'ignore TLS/SSL-errors'.

This issue might similar to #1302

🐻 Uptime-Kuma Version

1.17.1

💻 Operating System and Arch

Raspbian Bullseye

🌐 Browser

Firefox latest/stable for Windows 11

🐋 Docker Version

20.10.17, build 100c701

🟩 NodeJS Version

No response

Originally created by @HolgerAusB on GitHub (Aug 13, 2022). ### ⚠️ Please verify that this bug has NOT been raised before. - [X] I checked and didn't find similar issue ### 🛡️ Security Policy - [X] I agree to have read this project [Security Policy](https://github.com/louislam/uptime-kuma/security/policy) ### 📝 Describe your problem I am quite new to docker and kuma. I tried to monitor a local https server by name `https://sub1.example.com:1234` and it lasts me hours until I realized that kuma never got an ip of that server. The Raspi got its addresses from pihole, which would deliver back a local IP for that host name. But as kuma is in a container, there is a different dns server setting in the container which asks a dns server outside the local net. But as my https-server sub1 is not reachable from the internet, the check fails. So, is it possible somehow to set the dns server setting inside the docker container (or as new feature in kuma)? And/or is there a way to set a hosts file with static name>ip ? Meanwhile I set the monitor to `https://192.168.1.23:1234` and ckecked 'ignore TLS/SSL-errors'. This issue might similar to #1302 ### 🐻 Uptime-Kuma Version 1.17.1 ### 💻 Operating System and Arch Raspbian Bullseye ### 🌐 Browser Firefox latest/stable for Windows 11 ### 🐋 Docker Version 20.10.17, build 100c701 ### 🟩 NodeJS Version _No response_
deekerman 2026-02-28 02:17:42 -05:00
  • closed this issue
  • added the
    Stale
    help
    labels
Author
Owner

@HolgerAusB commented on GitHub (Aug 13, 2022):

I was just on the search for a JSON viewer and tested that with an kuma backup. There allready is a data field for the resolver in each monitor, but how can I edit this in kuma? Or do I need to manipulate that backup and upload this to kuma? will this be persistant?

            "dns_resolve_type": "A",
            "dns_resolve_server": "1.1.1.1",
@HolgerAusB commented on GitHub (Aug 13, 2022): I was just on the search for a JSON viewer and tested that with an kuma backup. There allready is a data field for the resolver in each monitor, but how can I edit this in kuma? Or do I need to manipulate that backup and upload this to kuma? will this be persistant? ``` "dns_resolve_type": "A", "dns_resolve_server": "1.1.1.1", ```
Author
Owner

@nbvcxz commented on GitHub (Aug 13, 2022):

As far as I understand, you need:
https://docs.docker.com/config/containers/container-networking/#dns-services or https://docs.docker.com/engine/reference/commandline/run/#add-entries-to-container-hosts-file---add-host
Not Uptime-Kuma specific. You just need to add appropriate parameter to your docker run or compose file.

@nbvcxz commented on GitHub (Aug 13, 2022): As far as I understand, you need: https://docs.docker.com/config/containers/container-networking/#dns-services or https://docs.docker.com/engine/reference/commandline/run/#add-entries-to-container-hosts-file---add-host Not Uptime-Kuma specific. You just need to add appropriate parameter to your `docker run` or compose file.
Author
Owner

@HolgerAusB commented on GitHub (Aug 13, 2022):

Thank you @nbvcxz that helped. But I think there shouldd be a (per monitor) option to set the resolver in kuma.

I have added a --dns 192.168.0.1 to the run command. Now the monitor works with domain name. Nevertheless in a new backup the resolver-line is unchanged at 1.1.1.1

docker stop uptime-kuma 
docker rm uptime-kuma
docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --dns 192.168.0.1 --name uptime-kuma louislam/uptime-kuma:1
@HolgerAusB commented on GitHub (Aug 13, 2022): Thank you @nbvcxz that helped. But I think there shouldd be a (per monitor) option to set the resolver in kuma. I have added a `--dns 192.168.0.1` to the run command. Now the monitor works with domain name. Nevertheless in a new backup the resolver-line is unchanged at 1.1.1.1 ``` docker stop uptime-kuma docker rm uptime-kuma docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --dns 192.168.0.1 --name uptime-kuma louislam/uptime-kuma:1 ```
Author
Owner

@lnxbil commented on GitHub (Aug 21, 2022):

The Raspi got its addresses from pihole, which would deliver back a local IP for that host name. But as kuma is in a container, there is a different dns server setting in the container which asks a dns server outside the local net.

Normally the container inherits the dns settings of the client (more precisely the internal docker dns server gets it's resolvers from /etc/resolv.conf when it starts), so it should work as it was intended and it also works for me exactly like I described. I just had the same problem and solved it by editing the docker host /etc/resolv.conf.

@lnxbil commented on GitHub (Aug 21, 2022): > The Raspi got its addresses from pihole, which would deliver back a local IP for that host name. But as kuma is in a container, there is a different dns server setting in the container which asks a dns server outside the local net. Normally the container inherits the dns settings of the client (more precisely the internal docker dns server gets it's resolvers from `/etc/resolv.conf` when it starts), so it should work as it was intended and it also works for me exactly like I described. I just had the same problem and solved it by editing the docker host `/etc/resolv.conf`.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 19, 2022):

We are clearing up our old issues and your ticket has been open for 3 months with no activity. Remove stale label or comment or this will be closed in 2 days.

@github-actions[bot] commented on GitHub (Nov 19, 2022): We are clearing up our old issues and your ticket has been open for 3 months with no activity. Remove stale label or comment or this will be closed in 2 days.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 22, 2022):

This issue was closed because it has been stalled for 2 days with no activity.

@github-actions[bot] commented on GitHub (Nov 22, 2022): This issue was closed because it has been stalled for 2 days with no activity.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/uptime-kuma#1332
No description provided.