Skip to content

--ancestor refers to container's original image tag, rather than current #27743

@syndicatedshannon

Description

@syndicatedshannon

Issue Description

I use ps or ls with --ancestor=IMAGE_NAME to find current image dependencies. Therefore, when I provide an image name I desire it to de-reference using current image names.

However, I believe the current behavior is to use image name string/metadata persisted when the container was created.

My understanding is that this also diverges from Docker behavior.

Steps to reproduce the issue

# 1. Build v1 and run a container from it
podman build -t mytest:latest - <<'EOF'
FROM alpine
RUN echo "version 1" > /version.txt
CMD ["cat", "/version.txt"]
EOF

podman run -d --name test_v1 mytest:latest

# 2. Record what image ID that container is using
echo "Container image ID:"
podman inspect -f '{{.Image}}' test_v1

# 3. Build v2 and retag latest to the new image
podman build -t mytest:v2 - <<'EOF'
FROM alpine
RUN echo "version 2" > /version.txt
CMD ["cat", "/version.txt"]
EOF

podman tag mytest:v2 mytest:latest

echo "Current mytest:latest ID:"
podman image inspect -f '{{.Id}}' mytest:latest

# 4. Now check ancestor
echo "Containers with ancestor=mytest:latest:"
podman ps -a --filter ancestor=mytest:latest --format '  {{.Names}}  {{.Image}}'

Describe the results you received

Containers with ancestor=mytest:latest:
  test_v1  localhost/mytest:latest

Describe the results you expected

Containers with ancestor=mytest:latest:

podman info output

host:
  arch: amd64
  buildahVersion: 1.42.0
  cgroupControllers:
  - cpu
  - memory
  - pids
  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: 98.22
    systemPercent: 0.32
    userPercent: 1.46
  cpus: 32
  databaseBackend: sqlite
  distribution:
    distribution: arch
    version: unknown
  eventLogger: journald
  freeLocks: 2044
  hostname: al1
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 6.17.9-arch1-1
  linkmode: dynamic
  logDriver: journald
  memFree: 60391407616
  memTotal: 100933214208
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.17.0-1
      path: /usr/lib/podman/aardvark-dns
      version: aardvark-dns 1.17.0
    package: netavark-1.17.0-1
    path: /usr/lib/podman/netavark
    version: netavark 1.17.0
  ociRuntime:
    name: runc
    package: runc-1.4.0-1
    path: /usr/bin/runc
    version: |-
      runc version 1.4.0
      spec: 1.3.0
      go: go1.25.4 X:nodwarf5
      libseccomp: 2.5.6
  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/user/1000/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: true
    seccompEnabled: true
    seccompProfilePath: /etc/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: ""
    package: ""
    version: ""
  swapFree: 3128856576
  swapTotal: 4294963200
  uptime: 128h 8m 14.00s (Approximately 5.33 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries: {}
store:
  configFile: /home/user/.config/containers/storage.conf
  containerStore:
    number: 4
    paused: 0
    running: 1
    stopped: 3
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/user/.local/share/containers/storage
  graphRootAllocated: 999187021824
  graphRootUsed: 668344659968
  graphStatus:
    Backing Filesystem: btrfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 84
  runRoot: /run/user/1000/containers
  transientStore: false
  volumePath: /home/user/.local/share/containers/storage/volumes
version:
  APIVersion: 5.7.0
  Built: 1763023417
  BuiltTime: Thu Nov 13 02:43:37 2025
  GitCommit: 0370128fc8dcae93533334324ef838db8f8da8cb
  GoVersion: go1.25.4 X:nodwarf5
  Os: linux
  OsArch: linux/amd64
  Version: 5.7.0

Podman in a container

No

Privileged Or Rootless

None

Upstream Latest Release

No

Additional environment details

No response

Additional information

I use a workaround for compatibility, because I love podman!

    local IMAGE_ID=$(podman image inspect --format '{{.Id}}' $IMAGE_NAME)
    podman ps -a --filter "ancestor=$IMAGE_ID"

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions