Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose volume not synced

PROBLEM

I use docker-compose for development with Python/Flask. I want my host codebase to sync with one inside docker container but not...

SITUATION

My working directory structure is below:

.
├── Dockerfile
├── docker-compose.yml
├── app.py
└── requirements.txt

I made bind mount from host's current directory to container's /app.

Dockerfile:

FROM python:3.7.3-alpine3.9

WORKDIR /app

COPY requirements.txt requirements.txt

RUN pip install --upgrade pip && \
  pip install -r requirements.txt

COPY . .

CMD gunicorn -b 0.0.0.0:9000 -w 4 app:app

docker-compose.yml:

version: '3'
services:
  web:
    build: .
    ports:
      - "4649:9000"
    volumes:
      - .:/app

When I access http://localhost:4649 I can see correct response so Docker container is working well. However response don't update when I change app.py.

I inspected the container and the result is below

"Mounts": [
            {
                "Type": "bind",
                "Source": "/Users/emp-mac-zakiooo/dev/jinja-pwa",
                "Destination": "/app",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],

It looks very right so I have no idea about this problem 😇

like image 379
zoshigayan Avatar asked Jul 05 '26 21:07

zoshigayan


1 Answers

OMG I found my files are correctly synced but gunicorn cached them so added --reload to CMD in Dockerfile, and finally it fixed. Thank you for helping and soooo sorry for my foolishness...!

like image 109
zoshigayan Avatar answered Jul 10 '26 06:07

zoshigayan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!