I have mounted one directory, see part of docker-compose.yml:
volumes:
- ../cloud/nginx:/etc/nginx
- ../cloud/html/:/var/www/html/
- ../cloud/test/test.html:/var/www/html/index5.html
where ../cloud/html/ is mounted to the directory /var/www/html/
and also mounted one file, ../cloud/test/test.html to the file /var/www/html/index5.html
Now, When I make changes on my local directory files i.e. files in the directory html, No matter which editor I use (whether it vim or nano), changes immediately do reflect on inside the container as well. {See image 1 for reference.}
1a) vim changes inode of index.html from 152624 to 152778.
1b) Newly added lines are reflected on container files as well.
However, when I make change to the mounted file, on my local, it depends on the editor I used. I mean, if I used nano as my editor, the changes are reflected immediately to inside the container as well, and no other errors do occur. However, if I used vim as my editor then, the changes doesn't reflect to the container, instead, ls command on container shows No such file or directory. {see image 2 for reference}
Using nano to change file test.html on local directory [test.html is mounted to index5.html]:
2a) editing with nano, changes immediately reflected inside the container.
Using vim to change the test.html:
2b) editing by vim
2c) editing with vim changes inode, so that container shows No such file or directory as older inode file doesnot exist in the local machine mounted volume directory.
This happens because, vim changes the inode value of the file when editing with vim, that's why our container would look for the older inode value of the file which has just been changed by the vim editor. Thus, container shows No such file or directory.
Now, I don't understand that, even on mounting a directory as a volume and editing a file within that directory, using vim also changes the inode of the file (on image 1a). Though this changed inode of the file on the volume mounted directory is also reflected on container as well. Why don't changed inode of the mounted file, when edited by vim, is not reflected on the file inside the container??
I guess, editing with nano has immediate change inside the container files as well, since, nano doesn't change inode value for file whether its within the volume mounted directory or is the file mounted itself. Correct me on this as well.
I understand that editing the mounted file using vim, requires me to first docker-compose down the containers and then again run docker-compose up, so that newly created containers will take new inode files (since, they don't know about the older inode or changes have been made).
However, editing the mounted file using nano has no such adverse effect.
And, editing the files within the mounted directory, using both vim or nano, has no adverse effect.
I expect: Why editing the mounted file using vim shows No such file or directory error inside the container. Please, elaborate.




