# Reusable Anchor Binds

## Overview

When working with storage in Docker, there are several ways to mount host directories or shares into containers. This section outlines different mounting strategies and explains how to make volume mounts reusable across multiple containers.

### Static Volume Mount

A **static volume mount** is the simplest way to connect a host directory to a container.

Example (pseudo code):

```yaml
io:
    image: repo.moovit24.de:443/mcp_io:4.10.2.0
    restart: always
    volumes:
      -mnt/helmut-share:/Volumes/helmut4-share
```

This setup mounts the specified host directory directly into the container.\
It’s easy to configure and works well for simple use cases.

However, it’s **static**, meaning that any changes to the mounted location (such as a re-mounted network share) may not automatically be reflected inside the container without restarting it.

### Dynamic Bind Mount

A more flexible and recommended approach is to use a **dynamic bind mount**, which provides better propagation of changes from the host to the container. For further information see: D[ynamic Share Mounts in Docker](/helmut4-releases/getting-started/additional-configurations/container-adjustments/dynamic-share-mounts-in-docker.md)

Example (pseudo code):

```yaml
io:
    image: repo.moovit24.de:443/mcp_io:4.10.2.0
    restart: always
    volumes:
      - type: bind
        bind:
          propagation: rslave
        source: /mnt/helmut4-share
        target: /Volumes/helmut4-share
```

This configuration allows the container to dynamically reflect updates made to the mounted share on the host system.

It’s particularly useful when multiple network shares need to be mounted into Docker.

The main drawback is that each container requiring these mounts must define all the bind configurations individually — which can lead to long and repetitive YAML files.

### Reusable x-binds

When multiple containers share the same mounts, **reusable bind definitions** can significantly simplify your Docker stack configuration.\
By defining bind mounts once using **YAML anchors**, you can reference them in any number of services.

Pseudo example:

```yaml
x-binds:
  helmut4-share: &helmut4-share
    type: bind
    bind:
      propagation: rslave
    source: /mnt/helmut4-share
    target: /Volumes/helmut4-share
  
  mam-share: &mam-share
    type: bind
    bind:
      propagation: rslave
    source: /mnt/mam-share
    target: /Volumes/mam-share
  
  playout: &playout
    type: bind
    bind:
      propagation: rslave
    source: /mnt/playout
    target: /Volumes/playout

fx:
    image: repo.moovit24.de:443/mcp_fx:4.x.x.x
    volumes:
      - *helmut4-share

io:
    image: repo.moovit24.de:443/mcp_io:4.x.x.x
    volumes:
      - *helmut4-share
      - *mam-share
      - *playout
      
hc:
    image: repo.moovit24.de:443/mcp_hc:4.x.x.x
    volumes:
      - *playout
```

#### Benefits of Using Anchors

* **Centralized configuration:** All bind definitions are declared once at the top of the stack file.
* **Consistency:** Ensures all containers use the exact same mount paths and options.
* **Easy maintenance:** Updating a single bind definition automatically affects all containers referencing it.
* **Cleaner YAML:** Reduces redundancy and keeps stack files shorter and easier to read.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.helmut.de/helmut4-releases/getting-started/additional-configurations/container-adjustments/dynamic-share-mounts-in-docker/reusable-anchor-binds.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
