Alpine Linux DNS Issue


I have a weird problem with DNS and my Alpine Container (latest version 3.18) on Ubuntu.

As soon as I use a custom network for the container, I cant resolv my hostnames anymore. I have to use IPs or the FQDN. This issue is exclusive for Alpine. The same with ubuntu works.

Steps to reproduce:

docker network create customnet
docker run --network customnet --rm alpine:latest ping linux-server-1
ping: bad address ‘linux-server-1’

docker run --network customnet --rm alpine:latest ping
reply from

So I created a Alpine Container for analysis and started a shell.
Inside that shell, I made changes to the /etc/resolv.conf file (set ndots:1) and then it suddenly works.

BUT it only works inside that shell. No matter how I set this option outside of the shell, it wont work.
Using the same container and execute a docker exec ping = Doesnt work.
Create a new container with --dns-opts =Doesnt work
docker run --network customnet --rm --dns-opt="ndots:1" alpine:latest ping linux-server-1

Setting the option itself works, I confirmed it with “cat /etc/resolv.conf”. Everything looks the same.

Setting all dns-options in a docker json config file = Doesn’t work.
There are no env variables leading to this. And I have no clue why this is happening.

You got any ideas?

Well… After updating docker on ubuntu to it’s latest version it worked just fine. No idea what causes the older docker version to not work proberly with alpine and/or the dns-opts, but honestly I don’t care :slight_smile:

Alpine’s (infamous) DNS issues were supposed to be fixed in 3.18 but I’ve also been experiencing DNS issues in any case.

Unfortunately I can’t easily upgrade Docker on this machine so it looks like the old fix of using a Debian slim base is going to be the workaround.

Thanks for the info, probably saved me a couple of hours!