Here's my docker-compose.yml
, it contains a web service, which mounts a folder locally so that upon any code change watchmedo
restarts the webapp
django server. It's a reverse proxy with nginx.
version: '3'
services:
webapp:
build:
context: .
dockerfile: ./web/Dockerfile
volumes:
- ./web/:/usr/src/app/
- staticfile_volume:/usr/src/app/public
entrypoint: >
watchmedo auto-restart --recursive
--pattern="*.py" --directory="."
gunicorn myapp.wsgi:application -- --bind 0.0.0.0:9000
nginx:
build:
context: .
dockerfile: ./nginx/Dockerfile
depends_on:
- webapp
volumes:
- staticfile_volume:/usr/src/app/public
volumes:
staticfile_volume:
My local file setup is like:
$ tree -L 2
.
├── docker-compose.yml
├── nginx
│ ├── Dockerfile
│ └── nginx.conf
└── web
├── Dockerfile
├── manage.py
├── myapp
├── public
└── static
But when I create a new file in web/public
(the same folder mounted as a shared volume between webapp
and nginx
services), I don't see it from inside the running webapp
container.
Yet, if I create a new file anywhere else in the web/
folder (which is also mounted as a separate volume), I see the change from inside the running webapp
container.
What is causing this? And how do I change this behavior?
(I need to be able to run python manage.py collectstatic
from inside the running container but output into my local hard drive's web/public
so I can build the production Docker images for deploy.)