簡體   English   中英

使用 Docker 將 Node/express 應用程序運行到 EC2 時出現 CloudWatch“UnknownEndpoint”錯誤

[英]CloudWatch "UnknownEndpoint" error when running Node/express app to EC2 using Docker

我嘗試使用 docker 圖像和此命令在 ec2 上運行節點/快速應用程序“ sudo docker run -it -p 127.0.0.1:3000:3000 name/app:latest" ,我收到以下錯誤:

UnknownEndpoint: Inaccessible host: `logs.us-east-1.amazonaws.com’ at port `undefined’. This service may not be available in the `us-east-1' region.
  at Request.ENOTFOUND_ERROR (/usr/app/node_modules/aws-sdk/lib/event_listeners.js:574:46)
  at Request.callListeners (/usr/app/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
  at Request.emit (/usr/app/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
  at Request.emit (/usr/app/node_modules/aws-sdk/lib/request.js:686:14)
  at error (/usr/app/node_modules/aws-sdk/lib/event_listeners.js:406:22)
  at ClientRequest.<anonymous> (/usr/app/node_modules/aws-sdk/lib/http/node.js:99:9)
  at ClientRequest.emit (node:events:527:28)
  at ClientRequest.emit (node:domain:475:12)
  at TLSSocket.socketErrorListener (node:_http_client:454:9)
  at TLSSocket.emit (node:events:527:28)
Emitted ‘error’ event on DerivedLogger instance at:
  at DerivedLogger.transportEvent (/usr/app/node_modules/winston/lib/winston/logger.js:639:12)
  at CloudWatchTransport.emit (node:events:539:35)
  at CloudWatchTransport.emit (node:domain:475:12)
  at Relay.<anonymous> (/usr/app/node_modules/winston-aws-cloudwatch/lib/index.js:15:41)
  at Relay.emit (node:events:527:28)
  at Relay.emit (node:domain:475:12)
  at Relay._onError (/usr/app/node_modules/winston-aws-cloudwatch/lib/relay.js:74:12)
  at /usr/app/node_modules/winston-aws-cloudwatch/lib/relay.js:53:57
  at processTicksAndRejections (node:internal/process/task_queues:96:5) {
 code: ‘UnknownEndpoint’,
 region: ‘us-east-1’,
 hostname: ‘logs.us-east-1.amazonaws.com’,
 retryable: true,
 originalError: Error: getaddrinfo EAI_AGAIN logs.us-east-1.amazonaws.com
   at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
  errno: -3001,
  code: ‘NetworkingError’,
  syscall: ‘getaddrinfo’,
  hostname: ‘logs.us-east-1.amazonaws.com’,
  region: ‘us-east-1’,
  retryable: true,
  time: 2022-11-17T15:06:46.985Z
 },
 time: 2022-11-17T15:06:46.985Z
}

AWS AMI :ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-20220912

"@aws-sdk/client-cloudwatch-logs": "^3.183.0", HTTPS 在服務器上啟用

如果我在 ec2 上克隆 repo 並使用“ pm2 --name appName start npm -- start ”運行它,它運行良好。

你能幫我理解如何解決這個問題嗎?

我通過使用帶有以下標志的 docker host.network 解決了這個問題docker -.network host ,如此所述。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM