a local flask server with debug mode on
151
this is a local flask server with debug mode enabled
to use it first set host path to location of index.py (its name must be index.py) and container path should be /root/path
then set root path of your project to /root if you need extra stuff from your project like env
and there you go, a local flask server up and running
to install a python library, go to the terminal of the container and install
the docker file:
# Use an official Python runtime as a parent image
FROM python:3.8-slim-buster
# Set the working directory in the container to /root
WORKDIR /root
# Install Flask, gunicorn, and python-dotenv
RUN pip install --no-cache-dir Flask==3.0.3 gunicorn==22.0.0 python-dotenv==1.0.0
# Set environment variables for Flask
ENV FLASK_APP=/root/api/index.py
ENV FLASK_DEBUG=1
# Make port 5000 available to the world outside this container
EXPOSE 5000
# Run Flask when the container launches, binding to port 5000
CMD ["sh", "-c", "pip install -r /root/api/requirements.txt && flask run --host=0.0.0.0"]
Content type
Image
Digest
sha256:d668dc853…
Size
47.7 MB
Last updated
over 2 years ago
docker pull thezakimaindocker/flask