Skip to content
Advertisement

flask app not running automatically from Dockerfile

My simple flask app is not automatically starting when I run in docker, though I have added CMD command correctly. I am able to run flask using python3 /app/app.py manually from container shell. Hence, no issue with code or command

JavaScript

I run docker container as

JavaScript

When I log in to docker container and run “ps -eaf” on Ubuntu shell of container, I do not see flask process running. So my question is why below line did not work in Dockerfile?

JavaScript

Advertisement

Answer

Running your docker container and passing the command /bin/bash is overriding the CMD [“/usr/bin/python3”, “/app/app.py”] in your Dockerfile.

CMD vs ENTRYPOINT Explained Here

Try changing the last line of your Dockerfile to

JavaScript

Don’t forget to rebuild your image after changing.

Or… you can omit the /bin/bash from the end of your docker run command and see if your app.py starts up successfully.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement