Docker系列 | SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Try again768

错误日志

[2022-05-12 16:53:01][error] [数据驾驶舱] 命令行任务异常,SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Try again768
[2022-05-12 16:54:06][error] [数据驾驶舱] 命令行任务异常,SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Try again768
[2022-05-12 16:59:12][error] [数据驾驶舱] 命令行任务异常,SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Try again768
[2022-05-12 17:14:32][error] [数据驾驶舱] 命令行任务异常,SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Try again768
[2022-05-12 17:15:34][error] [数据驾驶舱] 命令行任务异常,SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Try again768

关键是这个错误是偶尔的,一次可以一次又不可以

以上数据库连接是使用的阿里云RDS 外网地址如:rm-xxxxxxxxxxx.mysql.rds.aliyuncs.com

进入容器

# ping rm-xxxxxxxxxxxxxx.mysql.rds.aliyuncs.com
ping: bad address 'rm-xxxxxxxxxxxxxx.mysql.rds.aliyuncs.com'

# ping rm-xxxxxxxxxxxxxx.mysql.rds.aliyuncs.com
ping: bad address 'rm-xxxxxxxxxxxxxx.mysql.rds.aliyuncs.com'

 发现容器内没法ping通

解决方案:优化 DNS 解析  

在请求域名时,DNS 解析可能会超时或者失败导致网站无法访问

Linux

/etc/docker/daemon.json

"dns" : ["114.114.114.114","8.8.8.8"]

 

Windows  

Docker Desktop 配置文件增加DNS,设置docker启动配置。增加以下配置

  "dns": [
    "114.114.114.114",
    "8.8.8.8"
  ],

 增加后重启Docker,解决问题

  

posted @ 2022-05-12 17:49  Tinywan  阅读(176)  评论(0编辑  收藏  举报