Can’t access Docker Tomcat App runing in Elastic Beanstalk

I’ve have a Red Hat Enterprise Docker container where I install Tomcat and am running a custom Tomcat application. I wish to deploy it to Elastic Beanstalk. The application works as expected when I run it locally with Docker on my workstation at the IP: http://localhost:8080/ephemeral.server/login.jsp?goto=/ephemeral.server/html/next/index.jsp.

However; when I deploy it to Elastic Beanstalk, I cannot get it to work. The public domain provided times out and I cannot figure out why. I have tried to access both on port 8080 and port 80. For example, I take the Domain created for the environment and try to access my site. First tried 8080:

http://<beanstalk-app>.eba-8ebiumxm.us-east-1.elasticbeanstalk.com:8080/ephemeral.server/login.jsp?goto=/ephemeral.server/html/next/index.jsp 

Then I try on port 80:

http://<beanstalk-app>.eba-8ebiumxm.us-east-1.elasticbeanstalk.com/ephemeral.server/login.jsp?goto=/ephemeral.server/html/next/index.jsp 

Response is always:

“This site can’t be reached….refused to connect.
Try: Checking the connection”

Step 1: Build the Container (Docker run, Docker build):

FROM  --platform=linux/amd64 registry.access.redhat.com/ubi9/ubi:latest

# Install necessary packages 
RUN dnf update -y && 
    dnf install -y tar gzip unzip

# Add the JRE
COPY jre-8u411-linux-x64.tar.gz /opt/

# COPY and overwrite the catalina.properties
COPY catalina.properties /opt/

# Copy Server installer.
COPY Server.Installer.7.7.2.4484_linux.zip /opt

# Add the server.xml
ADD server.xml /opt

# Add Tomcat
COPY apache-tomcat-9.0.91.tar.gz /opt/


# Unzip the Installer.
RUN unzip /opt/Server.Installer.7.7.2.4484_linux.zip -d /opt

# Give run permissions to install script.
RUN chmod +x /opt/Server.Installer.7.7.2.4484_linux/install.sh

# Make an jre directory in opt and extract the contents
RUN mkdir -p /opt/jre && tar -xvf /opt/jre-8u411-linux-x64.tar.gz -C /opt/jre --strip-components=1

# Set JAVA_HOME and PATH
ENV JAVA_HOME /opt/jre
ENV PATH $JAVA_HOME/bin:$PATH

# Extract Tomcat
RUN tar -xvf /opt/apache-tomcat-9.0.91.tar.gz -C /opt

# Rename Tomcat
RUN mv /opt/apache-tomcat-9.0.91 /opt/tomcat

# Overwrite the server.xml with the connector properties. 
RUN mv /opt/server.xml /opt/tomcat/conf/

# Overwrite the catalina.properties with custom properties. 
RUN mv /opt/catalina.properties /opt/tomcat/conf/catalina.properties

# Remove the old tomcat directory.
RUN rm /opt/apache-tomcat-9.0.91.tar.gz

# Create tomcat group and user
RUN groupadd tomcat 
  && useradd -M -s /sbin/nologin -g tomcat tomcat

# Change ownership of the Tomcat directory
RUN chown -R tomcat:tomcat /opt/tomcat

RUN ls -l /opt/tomcat/lib/

# Set environment variables
ENV CATALINA_PID=/opt/tomcat/temp/tomcat.pid
ENV CATALINA_HOME=/opt/tomcat
ENV CATALINA_BASE=/opt/tomcat
ENV CATALINA_OPTS="-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
ENV evolven_server_root=/opt/tomcat
ENV EVOLVEN_SERVER_ROOT=/opt/tomcat

# Expose Tomcat port
EXPOSE 8080

# RUN mv /opt/Server.Installer.7.7.2.4484_linux/lib/*.jar /opt/tomcat/lib/ 


# Install it!
# RUN /bin/bash -c 'source /etc/environment && ./opt/Server.Installer.7.7.2.4484_linux/install.sh -t /opt/tomcat -d $DB_HOST -p 5432 -u $DB_USER -P $DB_PASSWORD -c $DB_NAME'
RUN ./opt/Server.Installer.7.7.2.4484_linux/install.sh -t /opt/tomcat -d someurl.rds.xxxxxx.us-east-1.rds.amazonaws.com -p 5432 -u postgres -P <omitted> -c postgres

# RUN rm -rf /opt/Server.Installer.7.7.2.4484_linux/

# Remove the Evolven Server Installer.
RUN rm /opt/Server.Installer.7.7.2.4484_linux.zip

# Remove the JRE
RUN rm /opt/jre-8u411-linux-x64.tar.gz

# Run Tomcat
# ENTRYPOINT ["/opt/tomcat/bin/catalina.sh", "run"]
# CMD ["/opt/tomcat/bin/catalina.sh", "run"]
# CMD ["tail", "-f", "/dev/null"]
USER tomcat

CMD ["/bin/bash", "-c", "/opt/tomcat/bin/catalina.sh start && tail -f /opt/tomcat/logs/catalina.out"]

Step 2: Created a Dockerrun.aws.json file referencing my Docker app like this:

{
  "AWSEBDockerrunVersion": "1",
  "Image": {
    "Name": "myrepo/tomcat-image",
    "Update": "true"
  },
  "Ports": [
    {
      "ContainerPort": "8080"
    }
  ]
}

Step 3: Then I run: “eb init”, “eb create my-tomcat-env”, “eb deploy”.

I looked at the security group and attached to the EC2 instance hosting my Beanstalk instance and opened an inbound port on 8080.

What else can I do to debug this?

Was able to get it working first thing that was the issue was adding a port mappings, and sizing.

  • Port Mappings: Mapped the containerPort to port 80.
  • Sizing: Changed the profile to m5.2xlarge from t3.micro (my app requires A LOT more memory than a t3.micro instance).

Here’s my updated Dockerrun.aws.json.

{
    "AWSEBDockerrunVersion": "1",
    "Image": {
        "Name": "bronette/tomcat-app",
        "Update": "true"
    },
    "Ports": [
        {
            "hostPort": 80,
            "containerPort": 8080
        }
    ],
    "Volumes": [],
    "Logging": "/var/log/nginx"
} 

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật