Docker Community Forums

Share and learn in the Docker community.

Docker Compose not synchronising file changes in volume

I’m trying to use Docker for a hobby Node JS project, and what I’m trying to do is to load up the Node image and mount my local files into the container for development. My docker-compose.yml file is as follows:

version: '3.7'
services:
  node:
    build: .
    command: npm run dev
    image: node
    ports:
      - "4000:3000"
    volumes:
      - .:/code
    working_dir: /code

In my container, I’m running the dev server of Next JS. Locally, I can run it just fine and when I save changes, it will automatically reload the page. However, when I run the Next JS server in a container, it will initially load fine, but any changes made afterwards will not be shown.

I have verified that my shared drive has been ticked, and have restarted Docker Desktop multiple times to no avail. I’ll mention too that I’m running Windows 10 Pro.

Any ideas?

docker-compose version:
docker-compose version 1.24.1, build 4667896b
docker-py version: 3.7.3
CPython version: 3.6.8
OpenSSL version: OpenSSL 1.0.2q 20 Nov 2018

docker version:
Client: Docker Engine - Community
Version: 19.03.1
API version: 1.40
Go version: go1.12.5
Git commit: 74b1e89
Built: Thu Jul 25 21:17:08 2019
OS/Arch: windows/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 19.03.1
API version: 1.40 (minimum version 1.12)
Go version: go1.12.5
Git commit: 74b1e89
Built: Thu Jul 25 21:17:52 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.2.6
GitCommit: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc:
Version: 1.0.0-rc8
GitCommit: 425e105d5a03fabd737a126ad93d62a9eeede87f
docker-init:
Version: 0.18.0
GitCommit: fec3683

docker-compose config
services:
node:
build:
context: E:\Users\User\WebstormProjects\nextjs-test
command: npm run dev
image: node
ports:
- published: 4000
target: 3000
volumes:
- E:\Users\User\WebstormProjects\nextjs-test:/code:rw
working_dir: /code
version: ‘3.7’

Changed files in volumes mounted from Windows will not trigger a reload of the application. The reason is that this is done with a CIFS mount where such information is not available.

Is there any way to trigger reloads of the application while using windows, or will I need to start developing in a linux VM?

I have the same problem with Perl applications and didn’t find a solution for it. Informations are missing already when you mount a Windows share into a Linux machine. Maybe it’s possible to write a PowerShell script with a FileSystemWatcher that executes a command in the container when a file is changed.
We are in the Docker forum here, so I don’t recommend that you develop in WSL. :wink: