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 linux-server-1.my-full-domain.com
reply from 192.168.0.10
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?