I'm going through this tutorial and I've successfully got the stack up and running.
What's bugging me is that when I change my code (in the web
service) on my host, it does automatically make the changes when I reload the page in the browser. I don't understand why it's doing that. Here's my docker-compose.yml
file:
web:
restart: always
build: ./web
expose:
- "8000"
links:
- postgres:postgres
- redis:redis
volumes:
- ./web:/usr/src/app
- ./web/static:/usr/src/app/static
env_file: .env
environment:
DEBUG: 'true'
command: /usr/local/bin/gunicorn docker_django.wsgi:application -w 2 -b :8000
nginx:
restart: always
build: ./nginx/
ports:
- "80:80"
volumes:
- /www/static
volumes_from:
- web
links:
- web:web
postgres:
restart: always
image: postgres:latest
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data/
redis:
restart: always
image: redis:latest
ports:
- "6379:6379"
volumes:
- redisdata:/data
I didn't think that this was gunicorn
doing the reloading because I believe gunicorn
needs the --reload
flag to actually do hot reloading.
This line means that you are mapping locations on your host to locations within your web container.
volumes:
- ./web:/usr/src/app
- ./web/static:/usr/src/app/static
Therefore any time you change you change code in the .web directory, it is updated within the container. If you don't want that to happen then you need to copy those directories when you build your container by specifying that in Dockerfile for that container.