How to build Docker Images for a Flask App

preview_player
Показать описание
Here are the steps:
Create a Flask app
Confirm the flask app can run
Add a Dockerfile to the src dir
Run command from terminal: docker image build -t docker-flask-test . (don’t miss the last .)
Run command: docker run -p 5000:5000 -d docker-flask-test
Note: we are binding the host port 5000 to the container port 5000. We are also running in detached mode so the terminal shows up in separate window and naming the container.
You will see the container ID appear, you can see the logs by typing in: docker container logs [Image ID]
docker container stop [ID] will stop the container
docker system prune will remove any stopped containers, unused volumes and networks, and dangling images.

Рекомендации по теме
Комментарии
Автор

Trust me, your explanation was clear & crisp. I could understand the concept pretty nicely now.

itechthink
Автор

This was super helpful, thanks a lot dude.

TheSkyCries
Автор

really great and so beautifully explained vincent. newbies will be quick to grab. thank you so much

SidharthKaushiksid
Автор

Very Nice Explanation, Sir.Needs More From You.

mithunchandra
Автор

Thank you so much, This helped me a lot!

RaviShankerReddyKarri
Автор

Thanks Vincent. You saved my time. Helpful

kidszoneJKR
Автор

Wanted to add an update since this video was released sometime ago...
If u encounter this error while building image, "You are using pip version 9.0.1, however version 21.2.3 is available."

Search and replace to latest version of alpine in Dockerfile. For me it was replacing "python:3.6.1-alpine" to "python:3.8.2-alpine"

anupamdey
Автор

Is there a way to debug the container thru pycharm?

triggerhappy
Автор

in the docker run command, to give a name to the container we should use --name.

RaviKiran_Me
Автор

Thanks so much, I was struggling to build my docker image the past couple of days. My only question would be is it possible to change the URL from "localhost:5000" to "127.0.0.1:5000" ?

adamasimolowo