skip to Main Content

I am running docker containers with WSL2. When I make changes to my files in the /client directory the changes are not reflected and I have to do docker compose stop client, docker compose build client and docker compose start client. If I cat a file after changing domething one can see the change.
Here is my Dockerfile:

FROM node:16.17.0-alpine

RUN mkdir -p /client/node_modules
RUN chown -R node:node /client/node_modules
RUN chown -R node:node /root
WORKDIR /client

# Copy Files
COPY . .

# Install Dependencies
COPY package.json ./
RUN npm install --force 

USER root

I alse have a /server directory with the following Dockerfile and the automatic image rebuild happens on file change there just fine:

FROM node:16.17.0-alpine

RUN mkdir -p /server/node_modules
RUN chown -R node:node /server/node_modules
WORKDIR /server

COPY . .

# Install Dependencies
COPY package.json ./
RUN npm install --force --verbose

USER root

Any help is appreciated.

2

Answers


  1. Chosen as BEST ANSWER

    Solved by adding the following to my docker-compose.yml:

    environment:
        WATCHPACK_POLLING: "true"
    

  2. Docker does not take care of the hot-reload.

    You should look into the hot-reload documentation of the tools you are building with.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search