TrafeX / docker-php-nginx

Docker image with PHP-FPM 8.3 & Nginx 1.24 on Alpine Linux
https://hub.docker.com/r/trafex/php-nginx
MIT License
1.33k stars 721 forks source link

Unable to set custom DNS #158

Closed goldmont closed 7 months ago

goldmont commented 7 months ago

Hi there,

I have a self-hosted Pi-hole instance that works fine and I would like to set it as DNS of a container based on this image. I've opened port 53 on my host too. I tried to add to my docker-compose.yml the dns key and setting the host IP address as its value but the container is still unable to resolve custom domains. I also tried to set the DNS inside the Docker daemon.json file but no luck. I don't know if this issue could be related to the base image you are using (Alpine). Could you help me? Thanks.

EDIT: I forgot to write that the container is able to resolve custom domains listed into the extra_hosts key of my docker-compose.yml. By the way this is not a solution because I have to resolve wildcard domains which are not supported by extra_hosts.

TrafeX commented 7 months ago

Hi @goldmont,

I don't think this issue is related to this specific image. Setting a different DNS server is something you can do via the Docker configuration as explained here: https://dockerlabs.collabnix.com/intermediate/networking/Configuring_DNS.html That will also change the DNS for all container.

goldmont commented 7 months ago

Hi @goldmont,

I don't think this issue is related to this specific image. Setting a different DNS server is something you can do via the Docker configuration as explained here: https://dockerlabs.collabnix.com/intermediate/networking/Configuring_DNS.html That will also change the DNS for all container.

Hi, I solved.

I had to specify the host IP address in the ports attribute into Pi-hole's docker-compose.yml. Then I've set the dns attribute into docker-php-nginx's docker-compose.yml. Now it's working. Thank you.