I have a php script which runs inside a docker (The php version is 7.2.34 on orcalelinux. ) it uses dns_get_records to fetch spf records for domains. For one particular domain it throws a warning:
Warning dns_get_record(): a temporary server error has occurred on line 7
and returns blank result.
I tried to run same script on php:7.2-fpm-alpine the result is same but a different warning:
Warning: dns_get_record(): Unable to parse DNS data received on line 7
But When I run the script on my wsl linux (Ubuntu with php version 7.2.34) the script executes without warning and returns valid result for same domain
Why is same php function behaving differently on three different environment, and how it can be fixed?
My host operating system is windows 11 Here is php script:
<?php
/* do some stuff*/
$spf = dns_get_record('somedomain',DNS_TXT);
print("---------------------------------SMC SPF record---------------------------------\n");
print("\n$spf\n");
print("---------------------------------SMC SPF record---------------------------------\n");
?>
I cannot expose domain name due to privacy issue.
After much research I found that docker from windows is messing up the name servers in the container so the domain name was not able to get resolved properly hence the temporary error. so I had to edit /etc/resolve.conf in my container to
1.1.1.1
and it started working properly. I still face issues with curl based APIs in the container so I have decided to run docker inside wsl2 instead.