When I clean [ shutil.rmtree(dir_name)
] mounted folder (docker) on Ubuntu 18 then files are not visible from docker in mount dir [/app
] after that, but the same approach works fine for MacOS.
Following command used to mount a directory:
docker run --rm -it --mount type=bind,source=dir_name,target=/app image_name
There are no errors on the docker side but looks like the mount stop working. Looks like an issue with shutil.rmtree, but I'm not sure. Is it a docker or shutil lib issue?
Steps to reproduce:
Create dir:
mkdri /tmp/mount_dir
touch /tmp/mount_dir/test.txt
docker run --rm -it --mount type=bind,source=/tmp/mount_dir,target=/app ubuntu
docker> ls /app
test.txt
Then run python script pyhton3.9 example.py
:
import shutil import os shutil.rmtree("/tmp/mount_dir") os.mkdir("/tmp/mount_dir") os.mkdir("/tmp/mount_dir/test_one")
Go to Docker:
docker>ls /app
test_one (when everything running on MacOS)
The empty result on Ubuntu. Mount doesn't work anymore.