Hello, Miguel Grinberg's Tutorial should get you started. He explains very thoroughly how to deploy a dockerized flask app. Hope it helps. Answer from dafer18 on reddit.com
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ devops โ€บ dockerize-your-flask-app
Dockerize your Flask App - GeeksforGeeks
April 3, 2025 - Create Dockerfile (without an extension) in the project folder and add the following content in it: # Use an official lightweight Python image FROM python:3.9-slim # Set the working directory WORKDIR /app # Copy project files into the container COPY . /app # Install dependencies RUN pip install -r requirements.txt # Expose port 5000 for Flask EXPOSE 5000 # Command to run the app CMD ["python", "app.py"]
๐ŸŒ
Medium
medium.com โ€บ @geeekfa โ€บ dockerizing-a-python-flask-app-a-step-by-step-guide-to-containerizing-your-web-application-d0f123159ba2
Dockerizing a Python Flask App: A Step-by-Step Guide to Containerizing Your Web Application | by GeeekFa | Medium
December 12, 2023 - # Use the official Python 3.8 slim image as the base image FROM python:3.8-slim # Set the working directory within the container WORKDIR /api-flask # Copy the necessary files and directories into the container COPY resources/ static/ util/ .env application.py requirements.txt /api-flask/ COPY resources/ /api-flask/resources/ COPY static/ /api-flask/static/ COPY util/ /api-flask/util/ COPY .env application.py requirements.txt /api-flask/ # Upgrade pip and install Python dependencies RUN pip3 install --upgrade pip && pip install --no-cache-dir -r requirements.txt # Expose port 5000 for the Flask application EXPOSE 5000 # Define the command to run the Flask application using Gunicorn CMD ["gunicorn", "application:app", "-b", "0.0.0.0:5000", "-w", "4"] ... If you run the following command, you will see the created Docker Image.
Discussions

How to dockerize a flask app
Hello, Miguel Grinberg's Tutorial should get you started. He explains very thoroughly how to deploy a dockerized flask app. Hope it helps. More on reddit.com
๐ŸŒ r/flask
3
1
July 18, 2023
Dockerize a Flask app with NGINX reverse proxy using Docker-Compose

Nice post! One point of criticism though:

Using bind mounts, as opposed to volumes, is not considered best practice for production workloads.

More on reddit.com
๐ŸŒ r/flask
16
29
December 19, 2018
Dockerizing a Python Flask Application

Nice article, some remarks:

  1. why use ubuntu? You can just use the python image as a base. Saves you from having to install python yourself.

  2. I personally like to put the uwsgi configuration in a ini file, and have uwsgi consume that.

  3. why use threads? You can configure uwsgi to be a "master" and have it spawn multiple subprocesses. This way you don't have to limit the container to one cpu.

More on reddit.com
๐ŸŒ r/docker
10
12
April 6, 2016
Need to dockerize a flask application.
Take it slow, thereโ€™s a lot to learn about docker so itโ€™s really important to build a solid understanding of how docker containers work. I recommend spending time learning how to build containers and how to expose ports. When youโ€™re comfortable with that, I recommend learning docker-compose to put all of your configuration into a yaml file and be able to start your application(s) consistently with one simple command. That said, your immediate need is to learn to build images. Create a dockerfile and use it to specify which base image you want to use, add files to the image, run commands to install dependencies, expose ports, and finally to run the container. Dockerfiles give you a way to reproduce docker images consistently. Itโ€™s like a recipe/script for building images. There are tons of tutorials out that fit your use case. Good luck and happy learning! More on reddit.com
๐ŸŒ r/docker
16
8
July 25, 2021
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ how-to-dockerize-a-flask-app
How to Dockerize a Flask Application
November 11, 2021 - This line specifically instructs Docker to run our Flask app as a module, as indicated by the "-m" tag. Then it instructs Docker to make the container available externally, such as from our browser, rather than just from within the container. We pass the host port: CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
๐ŸŒ
Medium
medium.com โ€บ geekculture โ€บ how-to-dockerize-your-flask-application-2d0487ecefb8
How to dockerize your Flask application | by Dinesh Kumar K B | Geek Culture | Medium
October 10, 2024 - from flask import Flask, jsonify app = Flask(__name__) @app.route("/hello", methods=["GET"]) def say_hello(): return jsonify({"msg": "Hello from Flask"}) if __name__ == "__main__": # Please do not set debug=True in production app.run(host="0.0.0.0", port=5000, debug=True) (docker-env) dinesh@dinesh % python my_flask.py * Serving Flask app 'my_sync' * Debug mode: on WARNING: This is a development server.
๐ŸŒ
Clickit Tech
clickittech.com โ€บ clickit home โ€บ our blogs โ€บ devops โ€บ how to dockerize a flask python application
How to Dockerize a Flask Python Application
February 12, 2025 - Nginx Reverse Proxy: We will create a Docker Image of Nginx to use as a Reverse Proxy, i.e. to forward user requests to a Python Application. Python Flask Application: We will create a simple Python Flask Application providing 3 APIs. This ...
๐ŸŒ
DevOps Cube
devopscube.com โ€บ dockerize-python-flask-application
Dockerize Flask Application: A Step-by-Step Guide
May 26, 2025 - Docker installed in your system. A Python Flask application file that has to be Dockerized.
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ devops โ€บ dockerizing-a-python-flask-application-with-a-database
Dockerizing a Python Flask Application with a Database - GeeksforGeeks
April 28, 2025 - The docker-compose.yml file is used to define services , networks ,ports, connection between containers and volumes. The ports are given to Flask app is 5000 and for database is 27017 ... web: build: . command: python -u app.py ports: - "5000:5000" volumes: - .:/app links: - db db: image: mongo:latest hostname: test_mongodb environment: - MONGO_INITDB_DATABASE=animal_db - MONGO_INITDB_ROOT_USERNAME=root - MONGO_INITDB_ROOT_PASSWORD=pass ports: - 27017:27017
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ containers โ€บ quickstart-python
Python in a container
November 3, 2021 - If your main module was in the root folder as a file named main.py and had a Flask instance variable was named myapp, the final argument in the command above will be "main:myapp". Within subfolders, the argument would be "subfolder1_name.subfolder2_name.main:myapp". The Containers: Add Docker Files to Workspace... command automatically creates a Docker launch configuration to build and run your container in debug mode. To debug your Python app container:
๐ŸŒ
DEV Community
dev.to โ€บ sre_panchanan โ€บ how-to-dockerize-a-flask-application-4mi
How to Dockerize a Flask Application ๐Ÿณ๐Ÿš€ - DEV Community
February 29, 2024 - Installs the Python dependencies listed in requirements.txt without caching to ensure the latest versions are fetched. ๐Ÿš€๐Ÿ”ง ... Copies the entire application code into the container's working directory. ๐Ÿ“‚๐Ÿ“„ ... Informs Docker that the application inside the container will use port 8080. ๐Ÿ”Œ๐Ÿ”ข ... Specifies the command to run when the container starts, launching the Flask application.
๐ŸŒ
zippyOPS
zippyops.com โ€บ how-to-dockerize-a-python-flask-application
How to Dockerize a Python Flask Application
Let's provide the information required for the container to start. We have only one service here, and the image name docker_flask. Run the app.py file with the make command. ... Now, start your container which starts your Python Flask web app.
๐ŸŒ
DEV Community
dev.to โ€บ pierangelo1982 โ€บ dockerize-a-flask-app-4pe
Dockerize a Flask App - DEV Community
October 27, 2020 - N.B: above I have set public ip 0.0.0.0, beacuse with 127.0.0.1 itโ€™s reachable only inside the container and not from the outside outside. create a file requirements.txt and insert all the pip libraries that your app require (in my case only ...
๐ŸŒ
LogRocket
blog.logrocket.com โ€บ home โ€บ build and deploy a flask app using docker
Build and deploy a Flask app using Docker - LogRocket Blog
June 4, 2024 - Run this command on your terminal within the root directory to perform this test: ... If you donโ€™t have Docker installed on your machine, you can follow these instructions to get started. Create a file and name it Dockerfile.
๐ŸŒ
AppSignal
blog.appsignal.com โ€บ 2025 โ€บ 08 โ€บ 06 โ€บ deploy-a-python-flask-app-to-render-with-docker.html
Deploy a Python Flask App to Render with Docker | AppSignal Blog
August 6, 2025 - In tasks.py, we initialize a Celery app and simulate a slow background task by using Python's built-in time module to add a 10-second delay. By separating the core Flask app from the Celery worker code, we ensure that our project is more modular and maintainable. Note: We have also supplied the environment variable CELERY_BROKER_URL, which will come in handy in the next deployment section. (For now, in local development mode, the code just grabs the default local rabbitmq broker url). Next, we will create a Dockerfile in the project root:
๐ŸŒ
TestDriven.io
testdriven.io โ€บ blog โ€บ dockerizing-flask-with-postgres-gunicorn-and-nginx
Dockerizing Flask with Postgres, Gunicorn, and Nginx | TestDriven.io
May 28, 2023 - Create a requirements.txt file in the "web" directory and add Flask as a dependency: ... โ””โ”€โ”€ services โ””โ”€โ”€ web โ”œโ”€โ”€ manage.py โ”œโ”€โ”€ project โ”‚ โ””โ”€โ”€ __init__.py โ””โ”€โ”€ requirements.txt ยท Install Docker, if you don't already have it, then add a Dockerfile to the "web" directory: # pull official base image FROM python:3.11.3-slim-buster # set work directory WORKDIR /usr/src/app # set environment variables ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 # install dependencies RUN pip install --upgrade pip COPY ./requirements.txt /usr/src/app/requirements.txt RUN pip install -r requirements.txt # copy project COPY .
๐ŸŒ
GitHub
github.com โ€บ shekhargulati โ€บ python-flask-docker-hello-world
GitHub - shekhargulati/python-flask-docker-hello-world: Hello world Python Flask application Dockerized
$ docker build -t simple-flask-app:latest . Run the Docker container using the command shown below. $ docker run -d -p 5000:5000 simple-flask-app ยท
Starred by 99 users
Forked by 433 users
Languages ย  Python 59.3% | Dockerfile 40.7% | Python 59.3% | Dockerfile 40.7%
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ how-to-build-and-deploy-a-flask-application-using-docker-on-ubuntu-20-04
How To Build and Deploy a Flask Application Using Docker on Ubuntu 20.04 | DigitalOcean
December 7, 2021 - Because youโ€™re making a basic test app in this tutorial, the syntax is unlikely to go out of date due to future updates to Flask, but if you wanted to be safe and still receive minor updates, you could specify that you donโ€™t want to install a future major version by specifying something like Flask>=2.0.2,<3.0. You can check for updates at the official website for Flask, or on the Python Package Indexโ€™s landing page for the Flask library. Save and close the file. You have successfully set up your Flask application and are ready to set up Docker.
๐ŸŒ
Medium
medium.com โ€บ @prateekbansalind โ€บ python-programs-4-dockerizing-your-flask-api-for-seamless-deployments-28c1842a92cb
Python Programs 4: Dockerizing Your Flask API for Seamless Deployments | by Prateek Bansal | Medium
August 14, 2023 - The Dockerfile contains commands to set up the image of our application. Hereโ€™s a Dockerfile tailored for our Flask API: # Use an official Python runtime as the base image FROM python:3.8-slim # Set the working directory in the container to /app WORKDIR /app # Copy the current directory (our Flask app) into the container at /app COPY .