CrashLoopBackOff 运行 循环:Docker 和 GraphQl 警告不健康连接被拒绝

CrashLoopBackOff Running Loop : Docker and GraphQl Warning Unhealthy connection refused

我是 docker 的新手,我遇到了这个错误我正在使用带 mongoDB 的 AMZ 平台和带 Docker 的 graphql 一切正常,因为我没有搞错所有的代码,我总是得到 运行 和 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-xxxxx' 的输出:

{"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)"}

如果有人可以让我调试更多这个错误或者我不知道...

错误 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。