prakhar1989 / docker-curriculum

:dolphin: A comprehensive tutorial on getting started with Docker!
https://docker-curriculum.com/
MIT License
5.67k stars 2.16k forks source link

Development Workflow - docker-compose/volumes mistake (?) #314

Open QuerQue opened 3 years ago

QuerQue commented 3 years ago

Hi, I went through this great course but I have a doubt in one section. After making changes in app.py (adding /hello routing) and no changes in docker compose yaml file. I was surprised when run docker-compose run web bash because it turned out that changes are visible in /opt/flask-app/app.py (of course container build based on image) I thought that maybe this is due to using different docker-compose version. So I installed 1.21.2 version. The result was the same. After more and more tests I came to conclusion that volumes is the option which makes problem.

   volumes:
      - ./flask-app:/opt/flask-app

To sum up. No matter if we have build: . or image: prakhar1989/foodtrucks-web. If there is a volume pointing to our host app.py changes will be visible and curl request to 0.0.0.0:5000/hello returns Hello World.

@prakhar1989 please take a look and if this description above is not correct let me know. Thank you :)

Maarti commented 1 year ago

I noticed the same thing.

It's the fact of mapping the volume that will take the local files (it doesn't matter if we use the image or the local build). And so changes to app.py will also be applied in the container (but won't be visible until the app has restarted).

It's actually passing the "DEBUG=True" variable that allows Flask to restart automatically when a change is made.