If a directory is volume mounted, all changes on the host should by visible in the docker container.
Actual behavior
If a directory within the mounted volume is deleted, then re-created with the same name, docker no longer sees the directory contents and cannot write to the directory any more.
Docker version
Client: Docker Engine - Community
Version: 24.0.2
API version: 1.43
Go version: go1.20.4
Git commit: cb74dfc
Built: Thu May 25 21:52:22 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 24.0.2
API version: 1.43 (minimum version 1.12)
Go version: go1.20.4
Git commit: 659604f
Built: Thu May 25 21:52:22 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.21
GitCommit: 3dce8eb055cbb6872793272b4f20ed16117344f8
runc:
Version: unknown
GitCommit:
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Yes. If you delete the folder on host the bind mount breakes and is not re-established when you re-create the folder (probably because internal low-level ids change).
Because I want to mount /dev/serial into the container, but if I unplug all serial devices, the /dev/serial folder will be deleted by udev. In this case, if I plug in a device again, the container won’t be able to recognize it.
The premise is that I don’t want to mount the entire /dev directory.