So my issue is very simple, but still can't get hold of it and it's not performing like I wanted to.
sample docker file:
FROM ubuntu:16.04
RUN apt-get update -y && \
apt-get install -y python3-pip python3-dev
COPY ./requirements.txt /requirements.txt
WORKDIR /
RUN pip3 install -r requirements.txt
COPY . /
RUN chmod a+x start.sh
EXPOSE 5000
CMD ["./start.sh"]
sample start.sh
#!/usr/bin/env bash
# sleep 600
nohup python3 /code/app.py &
python3 /code/helloworld_extract.py
sample flask app.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def index():
return """
<h1>Python Flask in Docker!</h1>
<p>A sample web-app for running Flask inside Docker.</p>
"""
if __name__ == "__main__":
app.run(debug=True, host='0.0.0.0')
So, my issue is as soon as I build the image and run it,
docker run --name flaskapp -p5000:5000 docker-flask:latest... I can't reach localhost:5000.
While if I get inside the container and run explict nohup command with python3 app.py. I can reach localhost.
So, why can't I reach the localhost host with run command?
The thing is I need to run 2 scripts one is flask and another one is helloworld_extract.py which eventually exit after writing some information to the files.
helloworld_extract.py) exit? Are you sure you don't want two containers here?