App running in Docker on EB refuses connecting to self

走远了吗. 提交于 2019-12-22 09:24:11

问题


I have a Play 2 web application, which I deploy to Elastic Beanstalk using Docker. In this web app, I start an Akka cluster. The starting procedure involves adding all nodes in the autoscaling group as seed nodes (including itself). On the first deploy to EB I specify to deploy to a VPC (I only select one availability zone).

When I run the app and start the cluster, I get the following message:

AssociationError [akka.tcp://cluster@localhost:2551] -> [akka.tcp://cluster@172.31.13.25:2551]: Error [Invalid address: akka.tcp://cluster@172.31.13.25:2551] [ akka.remote.InvalidAssociation: Invalid address: akka.tcp://cluster@172.31.13.25:2551 Caused by: akka.remote.transport.Transport$InvalidAssociationException: Connection refused: /172.31.13.25:2551

Where 172.31.13.25 is the IP of the EC2 instance, and 2551 is the port. In my Dockerfile I have "EXPOSE 9000 2551". In the EC2 Security Group I have enabled all inbound traffic to
0.0.0.0/0 (and all outbound traffic). In the VPC Network ACLs (and security groups) I've also opened for all traffic.

This is my Dockerfile

FROM dockerfile/java:latest
MAINTAINER a <a@b.de>
EXPOSE 9000 2551
ADD files /
WORKDIR /opt/docker
RUN ["chown", "-R", "daemon", "."]
USER daemon
ENTRYPOINT ["bin/myapp"]
CMD []

Why does my EC2 instance refuse a connection to itself on port 2551?


回答1:


Turns out this is not possible as of now using Docker on Elastic Beanstalk. It is, however, possible using Tomcat.

Using play/activator, you can deploy a WAR file. By injecting the following .ebextensions config file into the war file, I was able to get an extra port open between the EC2 instances:

Resources:
  ExtraPortsSGIngress:
    Type: AWS::EC2::SecurityGroupIngress
    Properties:
      GroupId: { "Ref" : "AWSEBSecurityGroup" }
      IpProtocol: "tcp"
      FromPort: "2551"
      ToPort: "2551"
      SourceSecurityGroupId: { "Ref" : "AWSEBSecurityGroup" }


来源:https://stackoverflow.com/questions/27381651/app-running-in-docker-on-eb-refuses-connecting-to-self

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!