0

I'm a beginner in docker and I have a folder called MovieFlix that contains a flask web service app with some html templates that I connect to a mongodb image from docker . I want to run my flask app as a docker image . For that I have succesfully created a DockerFile which I list below :

FROM ubuntu:16.04
MAINTAINER bill <bill@gmailcom>
RUN apt-get update
RUN apt-get install -y python3 python3-pip 
RUN pip3 install flask pymongo flask_bcrypt 
EXPOSE 80
WORKDIR "/MovieFlix"
COPY webservice.py . //copy the flask app i want to run 
COPY templates . //copy my html templates
CMD ["python3", "webservice.py", "--host", "0.0.0.0", "--port", "80"] 

My image is built succesfully however when I run docker -p 5000:80 flask(my image name ) and copy the url http://127.0.0.1:5000/ in my search engine I get that the page does not work and 127.0.0.1 did not send data I can run my webservice.py normally on vscode and the mongodb image is running so I do not think the problem is there and I run my flask app with

if __name__ == '__main__':
    app.run(debug=True, host='127.0.0.1', port=5000)

I would appreciate your help with guiding me to solve this issue . Thank you in advance .

Vasilis Skentos
  • 506
  • 11
  • 22
  • `app.run(host='127.0.0.1')` will be inaccessible from outside the container. You need to set that to `0.0.0.0`, or parse out the `--host` command-line option. – David Maze Jun 26 '20 at 17:17
  • @DavidMaze you mean to delete it and my port from the dockerfile ? – Vasilis Skentos Jun 26 '20 at 17:19
  • @DavidMaze I changed my host to 0.0.0.0 and I still could not connect . I got that the web page must have permanently moved to another address or could not be working – Vasilis Skentos Jun 26 '20 at 17:34

0 Answers0