Skip to content

Subpath with Docker Compose silently ignored #27171

Description

@JCBird1012

Issue Description

This is a duplicate of #25992 - but I'm reopening it to potentially get eyes on this again.

I don't believe this is an issue with upstream Docker Compose (though I may be entirely wrong) - I think this might be an issue with the Podman/Docker compatibility socket.

Steps to reproduce the issue

From this comment - #25992 (comment)

This is also a compatibility issue with vanilla docker-compose over the Podman socket. I don't think docker-compose does what Podman expects when it comes to subpath mounting.

I did a small experiment here - create a named volume, mount it into a container, and create two folders inside.

Jonathan@parula:~/containers$ podman compose version
Docker Compose version 2.36.0

Jonathan@parula:~/containers$ podman volume create subpath-test
subpath-test

Jonathan@parula:~/containers$ podman run --rm -it -v subpath-test:/subpath-test alpine:edge sh
/ # cd subpath-test/
/subpath-test # ls
/subpath-test # mkdir test1
/subpath-test # mkdir test2
/subpath-test # ls
test1  test2
/subpath-test # cd test1
/subpath-test/test1 # touch hello1
/subpath-test/test1 # ls
hello1
/subpath-test/test1 # cd ..
/subpath-test # cd test2
/subpath-test/test2 # ls
/subpath-test/test1 # touch hello2
/subpath-test/test1 # ls
hello2
/subpath-test/test2 # cd ..
/subpath-test # ls
test1  test2
/subpath-test # exit

Here's my docker-compose.yml

services:
  subpath-test:
    container_name: subpath-test
    image: alpine:edge
    volumes:
      - type: volume
        source: subpath-test
        target: /test1
        volume:
          subpath: test1
      - type: volume
        source: subpath-test
        target: /test2
        volume:
          subpath: test2

volumes:
  subpath-test:
    external: true
Jonathan@parula:~/containers$ podman compose run --rm -it subpath-test sh
/ # ls
bin    etc    lib    mnt    proc   run    srv    test1  tmp    var
dev    home   media  opt    root   sbin   sys    test2  usr
/ # cd test1
/test1 # ls
test1  test2

Inside /test1, I'd expect to find just the file hello1, instead the contents of the whole named volume.

This works correctly via the CLI -

Jonathan@parula:~/containers$ podman run -it --rm   --mount type=volume,source=subpath-test,target=/test1,volume-subpath=test1  alpine sh

/ # ls
bin    etc    lib    mnt    proc   run    srv    test1  usr
dev    home   media  opt    root   sbin   sys    tmp    var
/ # cd test1
/test1 # ls
hello1
/test1 #

Now, I'm not expecting Podman to adjust behavior to be compatible with docker-compose (if this really is expected behavior, that's what podman-compose is for) - but it's worth mentioning since many folks use the Podman socket with vanilla docker-compose.

Describe the results you received

Inside /test1, I'd expect to find just the file hello1, instead the contents of the whole named volume, however, using Docker Compose - I see the contents of both.

Describe the results you expected

See above.

podman info output

host:
  arch: amd64
  buildahVersion: 1.41.4
  cgroupControllers:
  - cpuset
  - cpu
  - io
  - memory
  - hugetlb
  - pids
  - rdma
  - misc
  - dmem
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-1:2.1.13-1
    path: /usr/bin/conmon
    version: 'conmon version 2.1.13, commit: 82de887596ed8ee6d9b2ee85e4f167f307bb569b'
  cpuUtilization:
    idlePercent: 94.34
    systemPercent: 4.34
    userPercent: 1.31
  cpus: 28
  databaseBackend: boltdb
  distribution:
    distribution: arch
    version: unknown
  eventLogger: journald
  freeLocks: 1437
  hostname: 302DerikCourt
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 6.16.8-arch3-1
  linkmode: dynamic
  logDriver: journald
  memFree: 64482029568
  memTotal: 134766096384
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.16.0-1
      path: /usr/lib/podman/aardvark-dns
      version: aardvark-dns 1.16.0
    package: netavark-1.16.1-1
    path: /usr/lib/podman/netavark
    version: netavark 1.16.1
  ociRuntime:
    name: crun
    package: crun-1.24-1
    path: /usr/bin/crun
    version: |-
      crun version 1.24
      commit: 54693209039e5e04cbe3c8b1cd5fe2301219f0a1
      rundir: /run/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-2025_09_19.623dbf6-1
    version: |
      pasta 2025_09_19.623dbf6
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    exists: true
    path: /run/podman/podman.sock
  rootlessNetworkCmd: pasta
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: false
    seccompEnabled: true
    seccompProfilePath: /etc/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.3.3-1
    version: |-
      slirp4netns version 1.3.3
      commit: 944fa94090e1fd1312232cbc0e6b43585553d824
      libslirp: 4.9.1
      SLIRP_CONFIG_VERSION_MAX: 6
      libseccomp: 2.5.6
  swapFree: 0
  swapTotal: 0
  uptime: 7h 9m 19.00s (Approximately 0.29 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - docker.io
store:
  configFile: /etc/containers/storage.conf
  containerStore:
    number: 58
    paused: 0
    running: 58
    stopped: 0
  graphDriverName: overlay
  graphOptions:
    overlay.mountopt: nodev
  graphRoot: /var/lib/containers/storage
  graphRootAllocated: 4000229359616
  graphRootUsed: 203488980992
  graphStatus:
    Backing Filesystem: f2fs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Supports shifting: "true"
    Supports volatile: "true"
    Using metacopy: "true"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 53
  runRoot: /run/containers/storage
  transientStore: false
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 5.6.1
  Built: 1757054398
  BuiltTime: Fri Sep  5 02:39:58 2025
  GitCommit: 1e2b2315150b2ffa0971596fb5da8cd83f3ce0e1
  GoVersion: go1.24.6
  Os: linux
  OsArch: linux/amd64
  Version: 5.6.1

Podman in a container

No

Privileged Or Rootless

Privileged

Upstream Latest Release

Yes

Additional environment details

Additional environment details

Additional information

Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.locked - please file new issue/PRAssist humans wanting to comment on an old issue or PR with locked comments.stale-issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions