I have a data
folder at the root of my filesystem
arthur@debian:~$ ls -la /data
total 36
drwxr-xr-x 9 root root 4096 Dec 13 09:45 .
drwxr-xr-x 21 root root 4096 Dec 13 10:08 ..
drwxr-xr-x 2 root root 4096 Jun 15 2020 500g2
drwxr-xr-x 6 root root 4096 Nov 16 18:20 quad_1
drwxr-sr-x 5 arthur arthur 4096 Dec 13 13:29 tera_1
drwxrwxr-x 6 root root 4096 Dec 7 00:00 tera_2
drwxr-xr-x 5 root root 4096 Sep 18 21:32 tera_3
drwxr-xr-x 6 root root 4096 May 5 2021 tera_4
I want to mount the entire directory as a docker volume, but the container must have readonly access. So I used :ro
sudo docker run -it --name testcontainer -v /data:/internal_data:ro --rm alpine:latest /bin/sh
When the shell spawns, I'm still able to write into the supposedly readonly container. Why is that ?
/ # touch /internal_data/test
touch: /internal_data/test: Read-only file system # Ok, container prevented from writing
/ # touch /internal_data/tera_1/test # This worked
/ # touch /internal_data/tera_2/test # This worked
/ # touch /internal_data/500g2/test
touch: /internal_data/500g2/test: Read-only file system # Ok, container prevented from writing
/ #