Skip to content

[Request]: Named volume pre-population from container image #729

Description

@skaegi

Feature or enhancement request details

When you mount an empty named volume to a container directory (like -v my_volume:/data), container run should automatically copy any existing files from that directory in the image into the volume on first use.

$ echo -e "FROM alpine\nRUN mkdir /xyz && touch /xyz/hello" > Dockerfile
$ container build -t myimage .

$ container run myimage ls -al /xyz/hello
-rw-r--r--    1 root     root             0 Oct  7 00:36 /xyz/hello

$ container v create xyz
xyz
$ container run -v xyz:/xyz myimage ls -al /xyz/hello
ls: /xyz/hello: No such file or directory

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added theissue type on Oct 7, 2025
  2. jglogan commented on Oct 7, 2025

    @jglogan
    Contributor
  3. katiewasnothere commented on Oct 13, 2025

    @katiewasnothere
    Contributor

    Closing, thanks @skaegi!

  4. jglogan commented on Oct 31, 2025

    @jglogan
    Contributor

    @katiewasnothere I don't see a reason for closing this? My comment was there to provide a reference to the behavior that @skaegi called out.

    Reopening this as it relates to another volume-related feature.

  5. katiewasnothere commented on Nov 3, 2025

    @katiewasnothere
    Contributor

    Sorry about that! Closing this was an error on my part.

  6. mungler commented on Jan 14, 2026

    @mungler

    Commenting to follow this one as my ticket #745 was closed in favour of this one :)

  7. melonfleet commented on Oct 18, 2026

    @melonfleet

    Named volumes and non-root images: ownership as well as contents

    Adding a data point to this issue (and #745, closed as its duplicate): beyond pre-populating contents, the ownership of a fresh named volume is what breaks most non-root images today.

    On container 1.5.0 a named volume is a freshly formatted ext4 filesystem whose root is owned by 0:0, mode 0755, and nothing from the image is copied in. An image that runs as a non-root user therefore can't write to its own data directory once a volume is mounted there.

    Tested on a Mac Studio (Apple silicon, macOS 27, container 1.5.0), each with a fresh named volume at the image's data path:

    Image Runs as (UID:GID) Mount path Result
    docker.io/grafana/grafana:13.2.3 472:0 /var/lib/grafana mkdir: can't create directory '/var/lib/grafana/plugins': Permission denied
    docker.io/prom/prometheus:v3.15.0 65534:65534 /prometheus open /prometheus/queries.active: permission denied
    docker.io/grafana/loki:3.7.8 10001:10001 /loki mkdir /loki/rules: permission denied
    docker.io/dpage/pgadmin4:9.18.0 5050:0 /var/lib/pgadmin cannot write to /var/lib/pgadmin
    quay.io/jupyter/datascience-notebook:2026-10-12 1000:100 /home/jovyan/work cannot write to /home/jovyan/work

    Reproduction:

    container volume create grafana-data
    container run --rm -v grafana-data:/var/lib/grafana docker.io/grafana/grafana:13.2.3
    # mkdir: can't create directory '/var/lib/grafana/plugins': Permission denied

    Workaround (confirmed — Grafana then starts and /api/health returns 200): chown only the mount root, once, from a root helper:

    container run --rm -v grafana-data:/mnt docker.io/library/busybox:1.37 chown 472:0 /mnt

    It works, but every tool has to know each image's UID:GID and run an extra VM before the real one.

    Docker avoids this by copying the image directory — contents and ownership — into an empty volume on first mount (docs).

    Two things that would help, either on its own:

    1. An owner for a new volume, e.g. container volume create --uid 472 --gid 0 grafana-data (or --opt uid=,gid= on the local driver).
    2. Optional Docker-compatible population of an empty volume from the image's mount path on first use, preserving ownership and modes.
  8. mungler commented on Oct 18, 2026

    @mungler

    @melonfleet excellent summary 🫡

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions