I am pretty new to Docker ( and all of the tools ). I am trying to setup a docker machine and container on my mac.
My container contains python web application powered by flask. I am running app with following statement
app.run(host='0.0.0.0', debug=True)
And this is what my docker-compose.yml looks like:
web:
build: .
ports:
- "5001:5001"
volumes:
- .:/volcode
When I try to load page hosted at 5001 (docker-machine-ip:5001), I don't see changes made to web application unless I do a
docker-compose build && docker-compose up
UPDATE:
This is my Dockerfile:
FROM ubuntu:14.04
RUN apt-get -yqq update
RUN apt-get install -yqq python2.7
RUN apt-get install -yqq python-dev
RUN apt-get install -yqq libpq-dev
RUN apt-get install -yqq python-psycopg2
RUN apt-get install -yqq python-pip
ADD . /code
WORKDIR /code
RUN pip install -r server/requirements.txt
CMD python server/src/rest_server.py
Also this is equivalent to hot loading. (debug=True) should reload changed python files.
app.run(host='0.0.0.0', debug=True)
UPDATE 2:
Note that mount point in docker-compose.yml and Dockerfile are different. Having same mount points is resulting in the following error.
python: can't open file 'server/src/rest_server.py': [Errno 2] No such file or directory
Since you are using machine, it is not possible to track the changes on your local file system. When you run docker-compose build && docker-compose up the content of your directory will be copied to the docker daemon inside the machine.
If you want to track your local changes, you have to run docker locally (which is not available to Mac users). But you can run a Linux vm with shared folders and a docker daemon running inside the vm, I guess.
This issue has been proposed to be an upcoming feature.
You can find another and longer answer here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With