簡體   English   中英

Elastic Beanstalk 上的多容器 Docker 環境中的容器連接被拒絕

[英]Connection refused for container in multicontainer Docker environment on Elastic Beanstalk

我想在 Elastic beanstalk 上部署一個 tomcat 容器作為多容器環境的一部分。

在本地一切正常

docker run -it --rm -p 8888:8080 tomcat:9.0

When opening http://localhost:8888/ in the browser, the HTTP status 404 with footer Apache Tomcat/9.0.34 appears which is expected because I'm using the official image that doesn't come with any services (that I'我知道)。

在此處輸入圖像描述

現在我想將此容器用作彈性 beantalk 集群中的接入點。

我 select Create Application並提供我的 Dockerrun.aws.json¹:

{
  "AWSEBDockerrunVersion": 2,
  "volumes": [],
  "containerDefinitions": [
    {
      "name": "vanilla-tomcat",
      "image": "tomcat:9.0",
      "essential": "true",
      "memory": 128,
      "portMappings": [
        {
          "hostPort": 8888,
          "containerPort": 8080
        }
      ],
      "mountPoints": []
    }
  ]
}

健康是綠色的,沒有錯誤,但是當我調用地址時,例如
curl http://vanillatomcat-env.eba-abc.eu-central-1.elasticbeanstalk.com/我得到
curl: (7) Failed to connect to vanillatomcat-env.eba-xy.eu-central-1.elasticbeanstalk.com port 80: Connection refused
curl http://vanillatomcat-env.eba-abc.eu-central-1.elasticbeanstalk.com:8888 Connection timed out

安全組有一個入站規則:

Type Protocol Port range Source     Description - optional
HTTP TCP      80         0.0.0.0/0  -

我需要配置什么才能訪問我的容器?

¹我故意只提供一個容器以保持簡單,但其他環境不是解決方案,它必須是多容器環境!

進步

  1. 根據 Marcin 的建議(我對 a 的理解),我在Configuration -> Software -> Environment properties下將aws:elasticbeanstalk:environment:process:default:Port設置為不同的值:

在此處輸入圖像描述

但這並沒有改變調用addressaddress:1234

  1. 我用 flask 進一步嘗試了同樣的事情,其中圖像是poroko/flask-demo-appcontainerPort是 5000。它再次在本地工作( docker run -it --rm -p 8888:5000 poroko/flask-demo-app ),但不是在彈性豆莖上,所以我認為這個問題不是特定於 tomcat 而是由於設置。

設置"hostPort": 80為我解決了這個問題。

暫無
暫無

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

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