How to run and host Flask in a Docker container

preview_player
Показать описание
I showcase how we can run a simple flask app that prints "Hello World!" to the screen from a docker container.

Commands:
Build a docker image:
docker build -t [tag] [dockerfile position]

Create and run Docker container
docker run -d -p [host port]:[container port] [docker image]

How to see all images
docker images

How to see all containers
docker ps

My channel publishes videos regarding programming, software engineering, especially python, Java and JavaFX. If that is what you are looking for then do not hesitate to join me on this journey!

Subscribe to my YouTube channel:
Рекомендации по теме
Комментарии
Автор

I owe you a comment and a thank you for this video! Been looking for something like this for a week. Just what I needed

SosaG
Автор

Very helpful tutorial, Thank you very much <3

dintoxic
Автор

From the Flask Doc: "When running publicly rather than in development, you should not use the built-in development server (flask run). The development server is provided by Werkzeug for convenience, but is not designed to be particularly efficient, stable, or secure." So only use this method for development.

sourcerer
Автор

am following this tutorial in 2023 using vs code running on mbp m1. I faced a flask is having an error "import flask could not be resolved Pylance(----). Any idea how to solve this issue?

jackq
Автор

the volume is so quiet even with an external speaker

KH-kgbm
Автор

In the last line where we have
CMD ["python3", "-m", "flask", "run", "--host=0.0.0.0"]

could we use
RUN python3 -m flask run --host="0.0.0.0"?

just to be consistent with the format of the earlier commands

nthapostle
Автор

my docker container exits as soon as its run. I cannot see localhost:5000

DarshanSingh-iqgq
Автор

When I use docker app. I cant port 5000:5000 it does not let me. When I change it i have no issues. I have problem when I put my docker into aws. Task definition starts and then stops

djohnworthy