Bind mount permits mount propagation

Permit mount propagation only when its direction and effect on nested mounts are required.

Description

Linux bind propagation controls which new mounts appear across a bind mount. shared propagates in both directions and slave from host to container. rshared and rslave apply those rules to nested mounts too.

Potential impact

A new mount can expose data to other containers. With bidirectional propagation, a container allowed to change mounts can also affect the host.

Remediation

Keep the default rprivate unless the service needs propagation. If it does, check the direction, nested mounts and sharing peers, limit who can change mounts, and test access. Docker Desktop does not support mount propagation.

Examples

Use your image and set ENVVAR to the base directory. Verify that the expanded host path $ENVVAR/.whew/path/datapath, mounted at /data, supports the chosen propagation.

Before

yaml
version: "3.2"
services:
  app:
    image: notreal
    volumes:
      - type: bind
        source: $ENVVAR/.whew/path/datapath
        target: /data
        bind:
          propagation: rshared

After

yaml
version: "3.2"
services:
  app:
    image: notreal
    volumes:
      - type: bind
        source: $ENVVAR/.whew/path/datapath
        target: /data
        bind:
          propagation: private

The example switches from rshared to private, which blocks propagation for this mount. Use rprivate to include nested mounts. Set file read and write permissions separately.

References