Mount host directory including subdirectories

Hi,

currently I am containerizing a production server. I am using docker compose to create multiple services which need to have access to multiple directories including the subdirectories.

My docker compose looks similar to this:

version: "3"
services:
  server:
    build:
      context: .
    volumes:
      - /path/host/data:/path/guest/data

The files within this directory are shown as expected inside of the container, however, the subdirectories are not.

Is this intended or do I have to specify some other flags to mount the subdirectories as well?

Thanks in advance!

By default a bind mounted directory includes sub-directories. Do they have the same/required permissions?

Yes, every file as well as every directory is owned by the same user and the permissions are the same. I am able to execute the scripts in the directory, also I am able to write in this directory. Mounting the subdirectories manually also works as expected, but I cannot mount all thousand subdirectories manually - Life is too short for that.

Are those subdirectories mounted to the host too? Also what kind of Docker are you using? Docker CE or Docker Desktop? Or maybe Docker CE installed as a snap package?

In case of a regular directory and regular Docker CE, subdirectories couldn’t be hidden. A bind mount is just adding another path alias to the same inode (file/folder id), so you would always see the same even if you have no access to the subdirectories in a container, you just couldn’t list the contents maybe and get an error message.

Are those subdirectories mounted to the host too?

No, the subdirectories exist on the host itself.

Also what kind of Docker are you using? Docker CE or Docker Desktop?

I am using Docker CE.

Or maybe Docker CE installed as a snap package?

Docker was installed via apt according the steps written in the documentation

In case of a regular directory and regular Docker CE, subdirectories couldn’t be hidden. A bind mount is just adding another path alias to the same inode (file/folder id), so you would always see the same even if you have no access to the subdirectories in a container, you just couldn’t list the contents maybe and get an error message.

Yes, this information fits my understanding of bind mounts, yet, those subdirectories are not mounted. It is quite mysterious to be honest, since mounting those subdirectories manually works like a charm.

I have tried different syntaxes for the bind mount, namely, specifying the the mounting options with type, target, etc.

Alright, I am losing my mind here. Suddenly, it works now.

I didn’t do nothing. Therefore, I cannot provide a guide to solve this. Just restart your system (?)