As the title says there are some DNS issues and sometimes when I try to curl inside my docker container https://api.stripe.com/v1/setup_intents it returns curl: (6) Could not resolve host: api.stripe.com. This issue does not happen if I try to curl other websites.
docker exec -it php-alpine /bin/sh
/var/www/html # curl https://api.stripe.com/v1/setup_intents
{ works. some json response }
/var/www/html # curl https://api.stripe.com/v1/setup_intents
curl: (6) Could not resolve host: api.stripe.com
/var/www/html # curl https://api.stripe.com/v1/setup_intents
curl: (6) Could not resolve host: api.stripe.com
/var/www/html # curl https://api.stripe.com/v1/setup_intents
{ works. some json response }
/var/www/html # curl https://api.stripe.com/v1/setup_intents
curl: (6) Could not resolve host: api.stripe.com
/var/www/html # curl https://api.stripe.com/v1/setup_intents
{ works. some json response }
and so on...
However when I exit my docker image this issue does not happen. I can curl that address hundreds of times on my Ubuntu system (working on WSL) and it has never gave me any error before.
I tried to curl that address simultaneously from my local Ubuntu system, and from the docker image and while everything worked on Ubuntu, I was still getting the same error in the docker image.
>Solution :
login to docker container and open this file /etc/resolv.conf and add this line inside:
nameserver 8.8.8.8
or just run this inside container:
echo "nameserver 8.8.8.8" > /etc/resolv.conf