Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.2K
Views
How can I make my docker container update on changes to my source files?

I'm building a Django/React app using docker-compose, and I'd like it to reload my apps when a change is made, so far I've tried adding CHOKIDAR_USEPOLLING, adding npm-watch to my package.json, but it doesn't seem to be able to detect changes in the host file.

Ideally I don't want to have to run docker-compose up --build every time I make a change since it's making development tedious.

edit: I should mention that the apps both reload running outside of docker (npm start (cra default) and python manage.py runserver) as expected.

Changes are detected inside the container, but the react app will not rebuild.

I'm using Windows 10 also.

Is there something wrong with my files or something else I should be doing here?

docker-compose.yml

version: "3.9"
   
services:
  db:
    container_name: db
    image: postgres
    volumes:
      - ./data/db:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
  backend:
    container_name: backend
    build: ./backend
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/core
    ports:
      - "8000:8000"
    depends_on:
      - db
  frontend:
    container_name: frontend
    build: ./frontend
    command: npm start
    volumes:
      - './frontend:/app/'
      - '/frontend/node_modules'
    ports:
      - "3000:3000"
    environment:
      - CHOKIDAR_USEPOLLING=true
    depends_on:
      - backend
    # Enable interactive terminal (crucial for react container to work)
    stdin_open: true 
    tty: true

backend Dockerfile

FROM python:3 
ENV PYTHONUNBUFFERED=1
WORKDIR /code/
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/

frontend Dockerfile

FROM node:16

WORKDIR /app/

COPY package*.json /app/

RUN npm install

COPY . /app/

EXPOSE 3000

CMD ["npm", "start"]
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Instead of copying you should mount volumes directly to the folder where you run the code on your docker image. In that way your code changes will be reflected in your app.

Example in docker-compose.yml:

volumes:
      - "local_source_destination:/server_source_destination"

In your frontend docker-compose-yml you have:

    volumes:
  - '.:/frontend/app'

but in your Dockerfile your have

COPY . /app/

So it seems like your are mixing up where to mount your volume. Make sure '.' is where your root of your code folder is or change it accordingly.

Try something like:

 volumes:
  - '.:/app'

As that seems to be the location your server wants your code to be.

If your code is correctly mounted to the right destination it might be that you are not running your watch script from inside the docker container. Try running:

docker exec -itw source_destination_in_container your_container_name command_to_run_watch
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!