Cannot edit certain files on a mounted volume

I work on several different nodejs projects at any given time and they all have different versions of NodeJS so instead of developing locally, I prefer to use docker.

My projects’ source code gets mounted into a docker image and then I use commands like the following to install dependencies:
docker-compose run worker npm install --save --save-exact MODULE_NAME

The benefit of this approach is that:
a) i’m not managing multiple nodejs versions on my local machine … they are inside the container image and don’t conflict with one another
b) i no longer forget to switch nodejs versions when switching in between projects on my terminal/CLI … each container has only one appropriate version of nodejs in it
c) i no longer install a dependency into my project using the wrong nodejs version … each container has only one appropriate version of nodejs in it

But recently running this:
docker-compose run worker npm install --save --save-exact MODULE_NAME
leads to the dependency being installed but the package.json file not being updated because of:
WARN saveError EBUSY: resource busy or locked, rename '/apps/package.json.2435009273' -> '/apps/package.json'

I was wondering what could cause a file to be singled out in a mounted volume and be locked away from edits?

1 Like

One scenario. The default user is root in the volume but not the container. If you install an image that switches user away from root, you need to chown the directory and files in the volume to the matching userid and groupid. Otherwise, the root file in the volume will get access errors unless they also happen to be world writeable.

I have the same use-case and I’m experiencing the same issue. Did you ever find a resolution?