Docker volume seeing corruption

I have a question about docker volumes.

I have a situation where I create a docker volume and that docker volume has 4 subdirectories created on it, /var/v1, /var/v2, /var/v3, and /var/v4. I have a test that runs in that docker which mounts this volume and that test launches 4 dockers which each of the 4 dockers mount and use their respective directories i.e. docker 1 uses /var/v1, docker 2 uses /var/v2 … In this scenario I see corruption in the files created in those directories.

Now I verified that the different dockers only used their respective directories, so I changed the above scenario to create 4 separate volumes, instead of 1 volume and subdirectories, and ran the same test, and ensure that docker 1 used volume 1 and docker 2 used docker 2, etc… this time I did not encounter any corruption.

Any idea why scenario 1 is seeing corruption

First of all, you are running containers, not Dockers. Dockers is an other brand and Docker is the name of the software and the company that created it.

As for the corruption, can you share an example code that help us to understand the situation better? I don’t know the reason of the corruption, but I also don’t know what kind of corruption you are talking about and how you write the filesystem. The docker storage drver and the backing filesystem can be important too, so please, share the output of docker info