Dynamic share mount into docker

Utilizing bind mounts in the stack/compose configuration allows the mounting of the root '/mnt' mount point into the Docker environment. Consequently, when a new share is added on the host side, it becomes available within the Docker system.

Notably, the file or directory does not need to exist on the Docker host beforehand; it is created on demand if absent. While bind mounts are highly performant, it is important to note that they depend on the host machine's filesystem having a specific directory structure available.

Exercise caution when using this function. The automatic/dynamic mounting of all sub-folders can pose a security risk.

We recommend discussing this internally with your IT department before proceeding.

The required modifications for this are straightforward and easily implemented:

Consider that the default basic /mnt:/Volumes mounting needs to be removed or changed to a comment, as this would lead to an issue when deploying the stack.

Configuration example docker bind
volumes:
      - type: bind
        bind:
          propagation: rslave
        source: /mnt
        target: /Volumes
      
      # Old static method to mount a share/folder
      #- /mnt:/Volumes
      
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro     
      

Last updated