#7134·buildah

COPY --link to a relative destination path breaks layer caching

Author: ptabCreated Sep 28, 2026Updated Sep 28, 2026
Labelskind/bug

Issue Description

When copying files into the image filesystem with COPY --link using a relative destination path (e.g. ./), layer caching breaks for the current and all following instructions.

Steps to reproduce the issue

  1. Use the following Containerfile (any file will do, this is just to help reproduce it quickly):
    containerfile
    FROM alpine:latest AS src
    RUN touch /file
    
    FROM alpine:latest AS absolute
    COPY --link --from=src /file /
    RUN pwd
    
    FROM alpine:latest AS relative
    COPY --link --from=src /file ./
    RUN pwd
  2. Build the absolute target:
    › podman build --target absolute .
    [1/2] STEP 1/2: FROM alpine:latest AS src
    [1/2] STEP 2/2: RUN touch /file
    --> f7c29bbb868d
    [2/2] STEP 1/3: FROM alpine:latest AS absolute
    [2/2] STEP 2/3: COPY --link --from=src /file /
    --> c7bdfd05dc58
    [2/2] STEP 3/3: RUN pwd 
    /
    [2/2] COMMIT
    --> 684403893c79
    684403893c79070f31593780c6a4385566d9105bab43167688f57b39d6ad7a55
  3. Build the absolute target again, confirm all layers are cached:
    › podman build --target absolute .
    [1/2] STEP 1/2: FROM alpine:latest AS src
    [1/2] STEP 2/2: RUN touch /file
    --> Using cache f7c29bbb868d5037e8c95c1364042c95190cba3a087ae0958a67e3f10e62bcf6
    --> f7c29bbb868d
    [2/2] STEP 1/3: FROM alpine:latest AS absolute
    [2/2] STEP 2/3: COPY --link --from=src /file /
    --> Using cache c7bdfd05dc581d1e21031ba0bbaddf13fa8c03bc0f9c9d0aa3a9937f489e0b4e
    --> c7bdfd05dc58
    [2/2] STEP 3/3: RUN pwd
    --> Using cache 684403893c79070f31593780c6a4385566d9105bab43167688f57b39d6ad7a55
    --> 684403893c79
    684403893c79070f31593780c6a4385566d9105bab43167688f57b39d6ad7a55
  4. Build the relative target:
    › podman build --target relative .
    [1/3] STEP 1/2: FROM alpine:latest AS src
    [1/3] STEP 2/2: RUN touch /file
    --> Using cache 63879315c45b9f32a0bff1edd3579d2653f98dfac11c3f8fdc5ca1c7b9c575c3
    --> 63879315c45b
    [3/3] STEP 1/3: FROM alpine:latest AS relative
    [3/3] STEP 2/3: COPY --link --from=src /file ./
    --> c8e8a4049768
    [3/3] STEP 3/3: RUN pwd
    /
    [3/3] COMMIT
    --> a825d8f3889f
    a825d8f3889f9d865190de481cd7179e6057d16198ea01c377de1d08c1637c93
  5. Build the relative target again, notice how none of its instructions are cached and they're all run again:
    › podman build --target relative .
    [1/3] STEP 1/2: FROM alpine:latest AS src
    [1/3] STEP 2/2: RUN touch /file
    --> Using cache 63879315c45b9f32a0bff1edd3579d2653f98dfac11c3f8fdc5ca1c7b9c575c3
    --> 63879315c45b
    [3/3] STEP 1/3: FROM alpine:latest AS relative
    [3/3] STEP 2/3: COPY --link --from=src /file ./
    --> 72e646bba520
    [3/3] STEP 3/3: RUN pwd
    /
    [3/3] COMMIT
    --> 5307046364a7
    5307046364a71f55536d49bb7237959d10d35ce328a31cf63ac75f980ee35388

Describe the results you received

No layer caching, severely degrading the experience when building large images with podman build.

Describe the results you expected

Expected layer caching to work when using relative destination paths, enabling very commonly used containerfiles like:

containerfile
FROM alpine:latest
WORKDIR /app
COPY --link files/ ./
RUN some-build-command .

podman version output

yaml
Client:       Podman Engine
Version:      6.1.2
API Version:  6.1.2
Go Version:   go1.27.1
Git Commit:   04f3aa430e6df81bea059978bc5bafbc846ba3e7
Built:        Wed Sep 16 02:01:23 2026
OS/Arch:      darwin/arm64

Server:       Podman Engine
Version:      6.0.2
API Version:  6.0.2
Go Version:   go1.26.5-X:nodwarf5
Git Commit:   b28edb9ad70ce4317dc762ee9ce0a6d081d154e9
Built:        Tue Jul 21 02:00:00 2026
OS/Arch:      linux/arm64

podman info output

yaml
Client:
  APIVersion: 6.1.2
  Built: 1789516883
  BuiltTime: Wed Sep 16 02:01:23 2026
  GitCommit: 04f3aa430e6df81bea059978bc5bafbc846ba3e7
  GoVersion: go1.27.1
  Os: darwin
  OsArch: darwin/arm64
  Version: 6.1.2
host:
  arch: arm64
  buildahVersion: 1.44.1
  cdiSpecDirs:
  - /etc/cdi
  - /var/run/cdi
  cgroupControllers:
  - cpu
  - io
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.2.1-2.fc44.aarch64
    path: /usr/bin/conmon
    version: 'conmon version 2.2.1, commit: '
  cpuUtilization:
    idlePercent: 99.37
    systemPercent: 0.17
    userPercent: 0.46
  cpus: 12
  databaseBackend: sqlite
  distribution:
    distribution: fedora
    variant: podman-machine-os
    version: "44"
  emulatedArchitectures:
  - linux/386
  - linux/amd64
  - linux/arm64be
  eventLogger: journald
  freeLocks: 2036
  hostname: localhost.localdomain
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 1000000
    uidmap:
    - container_id: 0
      host_id: 502
      size: 1
    - container_id: 1
      host_id: 100000
      size: 1000000
  kernel: 7.1.3-200.fc44.aarch64
  linkmode: dynamic
  logDriver: journald
  memAvailable: 0
  memFree: 16335421440
  memTotal: 33210773504
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    defaultNetwork: podman
    dns:
      package: aardvark-dns-2.0.0-1.fc44.aarch64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 2.0.0
    package: netavark-2.0.0-2.fc44.aarch64
    path: /usr/libexec/podman/netavark
    version: netavark 2.0.0
  ociRuntime:
    name: crun
    package: crun-1.28-1.fc44.aarch64
    path: /usr/bin/crun
    version: |-
      crun version 1.28
      commit: 54f16ffbefcd022bf032af768b5c5ce075c18bfc
      rundir: /run/user/502/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +JSON_C
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-0^20260611.ga9c61ff-1.fc44.aarch64
    version: |
      pasta 0^20260611.ga9c61ff-1.fc44.aarch64-pasta
      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: unix:///run/user/502/podman/podman.sock
  rootlessNetworkCmd: pasta
  rootlessPortForwarder: rootlessport
  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: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: true
  swapFree: 0
  swapTotal: 0
  uptime: 422h 5m 48.00s (Approximately 17.58 days)
  variant: v8
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  ghcr.io:
    Blocked: false
    Insecure: false
    Location: ghcr.io
    MirrorByDigestOnly: false
    Mirrors: null
    Prefix: ghcr.io
    PullFromMirror: ""
  search:
  - docker.io
store:
  containerStore:
    number: 3
    paused: 0
    running: 3
    stopped: 0
  graphDriverName: overlay
  graphOptions:
    overlay.mountopt: nodev
  graphRoot: /var/home/core/.local/share/containers/storage
  graphRootAllocated: 106678648832
  graphRootUsed: 33327325184
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 285
  runRoot: /run/user/502/containers
  transientStore: false
  volumePath: /var/home/core/.local/share/containers/storage/volumes
version:
  APIVersion: 6.0.2
  BuildOrigin: 'Copr: packit/podman-container-tools-podman-29249'
  Built: 1784592000
  BuiltTime: Tue Jul 21 02:00:00 2026
  GitCommit: b28edb9ad70ce4317dc762ee9ce0a6d081d154e9
  GoVersion: go1.26.5-X:nodwarf5
  Os: linux
  OsArch: linux/arm64
  Version: 6.0.2

Provide your storage.conf

toml
Not modified, using the standard provided by upstream.

Podman in a container

No

Privileged Or Rootless

Rootless

Upstream Latest Release

Yes

Installation Source

Distribution package (DNF, apt, yay)

Additional environment details

Additional environment details

Additional information

Podman installed through mise.

Source: podman-container-tools/buildah