Shamoon
Shamoon

Reputation: 43609

How can I map a port from Elastic Beanstalk to my Docker container for my Flask app?

My Dockerfile looks like:


FROM ubuntu:18.04
RUN apt-get -y update
RUN apt-get install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update -y
RUN apt-get install -y python3.7 build-essential python3-pip
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
ENV FLASK_APP application.py
COPY . /app
WORKDIR /app
RUN pip3 install --no-cache-dir -r requirements.txt
EXPOSE 5000
ENTRYPOINT python3 -m flask run --host=0.0.0.0

So my app runs on port 5000. When I try to deploy to ElasticBeanstalk, how can I specify that it should forward to port 5000?

In my ELB, I have: enter image description here

I've seen some answers using Dockerfile.aws.json, but I don't think I need that since I won't be publishing my Docker image. Is that right?

In my application logs, I see:

 * Serving Flask app "application.py"
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

Upvotes: 3

Views: 645

Answers (1)

Marcin
Marcin

Reputation: 238877

The ports are set using Dockerrun.aws.json v1.

The Image option is optional if you have your own Dockerfile.

The Ports option:

Lists the ports to expose on the Docker container. Elastic Beanstalk uses the ContainerPort value to connect the Docker container to the reverse proxy running on the host.

Upvotes: 1

Related Questions