简体   繁体   中英

Connection refused for container in multicontainer Docker environment on Elastic Beanstalk

I want to deploy a tomcat container as part of a multicontainer environment on Elastic beanstalk.

Everything works fine locally with

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'm aware of).

在此处输入图像描述

Now I want to use this container as access point in a cluster on elastic beanstalk.

I select Create Application and supply my Dockerrun.aws.json¹:

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

Health is green, there are no errors, but when I call the address, eg
with curl http://vanillatomcat-env.eba-abc.eu-central-1.elasticbeanstalk.com/ I get
curl: (7) Failed to connect to vanillatomcat-env.eba-xy.eu-central-1.elasticbeanstalk.com port 80: Connection refused
with curl http://vanillatomcat-env.eba-abc.eu-central-1.elasticbeanstalk.com:8888 I get Connection timed out .

The security group has one inbound rule:

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

What do I need to configure to be able to access my container?

¹I'm purposefully only supplying one container to keep things simple but other environments are not a solution, it has to be a multicontainer environment!

Progress

  1. On (my understanding of a) suggestion by Marcin I set aws:elasticbeanstalk:environment:process:default:Port to different values under Configuration -> Software -> Environment properties :

在此处输入图像描述

But this did not change anything for calling either address or address:1234

  1. I've further tried the same thing with flask where the image is poroko/flask-demo-app and the containerPort is 5000. Again it works locally( docker run -it --rm -p 8888:5000 poroko/flask-demo-app ), but not on elastic beanstalk, so I assume that this problem is not specific to tomcat but due to the setup.

Setting "hostPort": 80 solved it for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM