Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File watch mode doesn't work in docker #462

Open
timbarclay opened this issue Mar 24, 2023 · 1 comment
Open

File watch mode doesn't work in docker #462

timbarclay opened this issue Mar 24, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@timbarclay
Copy link

timbarclay commented Mar 24, 2023

Describe the bug
When using Docker with a local volume, as described in the docs, the server doesn't respond to file changes in the mounted volume.

To Reproduce
Create local directories, e.g.

test/
├── mocks/
│   ├── routes/
│   │   └── route.json
│   └── collections.json

with a valid routes and collections in route.json and collections.json respectively.

Then run mocks-server in docker mounting the test directory as a volume

docker run -ti -p 3100:3100 -p 3110:3110 -v C:\test:/input mocksserver/main

Go to the URL configured in route.json, it should return as expected. Now change the route in route.json so that it returns something else. It will continue to return the initial response.

Expected behavior
If a file in the mocks/ directory is updated, the mocks-server should pick up that change and server whatever the current response is.

Operating system, Node.js an npm versions, or browser version (please complete the following information):

  • OS: Windows 10
  • Docker: 20.10.22

Additional context
If you open a shell inside the docker container and check the file, it is updated as expected, so it seems to be mocks-server not responding to the file change rather than docker not updating the file inside the container.

@javierbrea
Copy link
Member

Hi @timbarclay ,
You're right, thank your for sharing! The core of the project is using node-watch for watching the files, and it seems to be a wrapper for the node method fs.watch. I have just found a caveat about that method in the NodeJS documentation:

If the underlying functionality is not available for some reason, then fs.watch will not be able to function. For example, watching files or directories can be unreliable, and in some cases impossible, on network file systems (NFS, SMB, etc), or host file systems when using virtualization software such as Vagrant, Docker, etc.

So, this issue has not an easy solution, apart from trying to find another library without problems with virtualization, and replace the dependency.

@javierbrea javierbrea added the bug Something isn't working label Apr 7, 2023
@javierbrea javierbrea moved this to To do in Backlog May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: To do
Development

No branches or pull requests

2 participants