Skip to content

volumes: entries that bind-mount a single file are silently dropped #93

Closed

Description

@csaller

Summary

In container-compose 0.11.0, volumes: entries where the host side is a single file (rather than a directory) are silently omitted from the generated container spec. Directory mounts in the same service are forwarded correctly. Apple container itself handles file-to-file bind mounts fine when passed --volume host/file:container/file[:ro] directly, so the bug lives in the compose → container run translation.

Symptom in practice: services that rely on a mounted config file (very common in docker-compose land — ./config.yaml:/app/config.yaml:ro, ./init-database.sh:/docker-entrypoint-initdb.d/…, ./firebase.json:/firebase/firebase.json:ro, etc.) start up and immediately fail because the file isn't present inside the container.

Possibly related: closed issue #6 had the same shape (./init-database.sh:/docker-entrypoint-initdb.d/init-data.sh:Z). Reproducing cleanly on current 0.11.0 with this minimal case.

Environment

Tool Version
container 0.12.3 (build f989901)
container-compose 0.11.0 (Homebrew)
macOS Darwin 25.4.0 (Apple Silicon)

Minimal reproduction

.
├── docker-compose.yml
├── hello.txt           # host file for the single-file mount
└── data/
    └── marker.txt      # host file inside a directory mount

hello.txt:

hello from a single-file bind mount

data/marker.txt:

hello from a directory bind mount

docker-compose.yml:

services:
  repro:
    image: docker.io/library/alpine:3.20
    command:
      - sh
      - -c
      - |
        echo '--- /app listing ---'
        ls -la /app || true
        echo '--- file mount (/app/hello.txt) ---'
        cat /app/hello.txt 2>&1 || echo 'FILE MOUNT MISSING'
        echo '--- directory mount (/app/data/marker.txt) ---'
        cat /app/data/marker.txt 2>&1 || echo 'DIR MOUNT MISSING'
    volumes:
      - ./data:/app/data
      - ./hello.txt:/app/hello.txt:ro

Run:

container-compose up

Observed

container inspect container-compose-issue-repro | jq '.[0].configuration.mounts':

[
  {
    "source": "/Users/.../container-compose-issue/data/",
    "destination": "/app/data",
    "type": { "virtiofs": {} },
    "options": []
  }
]

Only one mount — the directory. The ./hello.txt:/app/hello.txt:ro entry is absent from the container spec entirely; there's no warning or error in container-compose up output about it being skipped.

Container stdout confirms:

--- /app listing ---
drwxr-xr-x    3 root     root          4096 May  8 18:39 data
--- file mount (/app/hello.txt) ---
cat: can't open '/app/hello.txt': No such file or directory
FILE MOUNT MISSING
--- directory mount (/app/data/marker.txt) ---
hello from a directory bind mount

Also reproduces with:

  • ./hello.txt:/app/hello.txt (no :ro)
  • /absolute/path/to/hello.txt:/app/hello.txt

In every variant the file mount is dropped and only the directory mount survives. (Note the trailing / the translator adds to the directory source — it looks like mounts are only emitted when the source resolves to a directory.)

Control: container run handles file mounts fine

Passing the same two binds directly to container run works:

container run --rm \
  --volume "$(pwd)/data:/app/data" \
  --volume "$(pwd)/hello.txt:/app/hello.txt:ro" \
  docker.io/library/alpine:3.20 \
  sh -c 'cat /app/hello.txt; cat /app/data/marker.txt'
hello from a single-file bind mount
hello from a directory bind mount

So Apple container 0.12.3 supports file-to-file bind mounts (including :ro). The drop happens during compose's YAML → container run translation.

Expected

A volumes: entry whose host side is a file path should be forwarded to container run as --volume hostfile:containerfile[:ro], just like the directory case. At minimum, if file mounts are intentionally unsupported, they should produce a visible warning rather than being silently omitted.

Workaround

For services that only need a single config file, move it into a directory that is already bind-mounted, and override the command to point at the new path — e.g. keeping ./.data:/app/.data as the only mount and placing config.yaml inside .data/.

Activity

  1. added a commit that references this issue on May 29, 2026
    4912c91
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions