Specific file in bind-mount directory does not update in Docker container when editing on host?

Viewed 421

I am trying to develop a project locally using Docker Compose and to prevent re-building my image on every update, I've added a bind-mount that maps my src directory to my WORDIR in Docker. All changes made on my local machine are then reflected in my Docker container...EXCEPT for one file. For some reason, there's a single file in my project, that when I change its contents, the change is not reflected in the Docker container even though other files adjacent to this file DO detect file changes. Which leads me to believe that the directory is mapped correctly but it's some other issue with the file itself?

docker-compose.yaml

graphql:
  build:
    context: .
    dockerfile: ./app/graphql/src/Dockerfile
    target: development
  volumes:
    - ./app/graphql/src:/workspace
    - /workspace/node_modules/

Dockerfile

# ------------> Base Image
FROM node:14 AS base

WORKDIR /workspace

COPY ./app/graphql/src .

# ------------> Development Image
FROM base AS development

CMD ["npm", "run", "dev"]

I haven't figured out how to show directory structure but the files that I am modifying are located in:

/app/graphql/src/api/graphql

Where file a.ts detects changes and is reflected in the Docker container but b.ts does not. I read about how Docker depends on the inode of the file to match if bind mounting specific files. I'm mounting a directory, but for a sanity check, I ran:

ls -i

in both the host and container and confirmed that the inodes matched.

I have two M1 Mac computers and I confirmed that this is a problem between both machines.

Any additional thoughts to debug this problem? My only other thought is that I hit a max number of files that can be tracked, but that's why I removed the node_modules. Any assistance would be really helpful!


EDIT: I created a new file, c.ts and duplicated the contents of b.ts (the file that wasn't changing between host and container)...and c.ts detects changes properly! Is there a way to inspect why a certain file isn't broadcasting changes? This is so strange.

1 Answers

You should remove COPY ./app/graphql/src . directive from your Dockerfile because this folder will mounted to container as volume.

Related