首页 > 解决方案 > CrashLoopBackOff 运行循环:Docker 和 GraphQl 警告不健康连接被拒绝

问题描述

我是 docker 新手,我遇到了这个错误我正在使用 AMZ 平台和 mongoDB 和 graphql 和 Docker 一切工作正常,因为我没有编写所有代码,而且我一直在运行和 CrashLoopBackOff :(我不知道为什么!这就是我得到的:

enter code here
NAME                       READY   STATUS             RESTARTS   AGE
graphql-xxxxxxxxxx-xxxxx   0/1     CrashLoopBackOff   8          12m
graphql-xxxxxxxxxx-xxxxx   0/1     CrashLoopBackOff   7          11m

'kubectl describe pod graphql-xxxxxxxxxx-xxxxx' 的输出:

Warning  Unhealthy  11m (x9 over 12m)      kubelet, pool-g1r6uxpbs-a1jl  Liveness probe failed: Get https://10.244.0.5:4000/healthz: dial tcp 10.244.0.5:4000: connect: connection refused
 Warning  BackOff    3m22s (x24 over 9m3s)  kubelet, pool-g1r6uxpbs-a1jl  Back-off restarting failed container

是的,我仔细检查了我的白名单并添加了我当前的 IP。'kubectl describe logs graphql-xxxxxxxxxx-xxxxxx' 的输出:

{"message":"Starting server with args []...","level":"info"}
{"message":"External IP 167.172.52.238","level":"info"}
{"message":"connection error:Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/","reason":{"type":"ReplicaSetNoPrimary","setName":null,"maxSetVersion":null,"maxElectionId":null,"servers":{},"stale":false,"compatible":true,"compatibilityError":null,"logicalSessionTimeoutMinutes":null,"heartbeatFrequencyMS":10000,"localThresholdMS":15,"commonWireVersion":null},"level":"error","stack":"MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/\n    at NativeConnection.Connection.openUri (/home/graphql/node_modules/mongoose/lib/connection.js:826:32)\n    at Mongoose.connect (/home/graphql/node_modules/mongoose/lib/index.js:335:15)\n    at Object.connect (/home/graphql/db/mongo.js:26:33)\n    at Object.<anonymous> (/home/graphql/index.js:83:44)\n    at Module._compile (internal/modules/cjs/loader.js:778:30)\n    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)\n    at Module.load (internal/modules/cjs/loader.js:653:32)\n    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)\n    at Function.Module._load (internal/modules/cjs/loader.js:585:3)\n    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)\n    at startup (internal/bootstrap/node.js:283:19)\n    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)"}

请如果有人可以给我一个机会来调试更多这个错误,或者我不知道......

标签: javascriptdockerkubernetesgraphql-jsdocker-container

解决方案


该错误getaddrinfo EAI_AGAIN表明您的 docker 环境无法访问互联网。因此,对外部 API 的调用失败。

一个简单的解决方法是创建文件/etc/docker/daemon.json

并插入:

{
    "dns": ["10.0.0.2", "8.8.8.8"]
}

其中 10.0.0.2 是您的机器请求记录的第一个 DNS 服务器,而 8.8.8.8 是备用 DNS 服务器,在这种情况下是 google。


推荐阅读