正如標題所說,存在一些 DNS 問題,有時當我嘗試在我的 docker 容器內卷曲時,https://api.stripe.com/v1/setup_intents它會回傳curl: (6) Could not resolve host: api.stripe.com. 如果我嘗試卷曲其他網站,則不會發生此問題。
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...
但是,當我退出 docker 映像時,不會發生此問題。我可以在我的 Ubuntu 系統(在 WSL 上作業)上卷曲該地址數百次,而且它以前從未給我任何錯誤。
我試圖同時從我的本地 Ubuntu 系統和 docker 鏡像中 curl 該地址,雖然一切都在 Ubuntu 上運行,但我仍然在 docker 鏡像中遇到相同的錯誤。
uj5u.com熱心網友回復:
登錄到 docker 容器并打開此檔案/etc/resolv.conf并在其中添加以下行:
nameserver 8.8.8.8
或者只是在容器內運行它:
echo "nameserver 8.8.8.8" > /etc/resolv.conf
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/381837.html
下一篇:如何在代碼中設定斷點來除錯PHP
