Skip to content

--cache-to causes compression_format from containers.conf to be ignored #6660

@jiridanek

Description

@jiridanek

Description

When using podman build --cache-to, the compression_format setting from containers.conf is ignored for both the cache layers AND the final image. Without --cache-to, the compression format is respected correctly.

Steps to Reproduce

  1. Create a minimal containers.conf with zstd:chunked:
[engine]
compression_format="zstd:chunked"
  1. Create a minimal Dockerfile:
FROM alpine:latest
RUN echo "layer1" > /layer1.txt
RUN echo "layer2" > /layer2.txt
  1. Build and push WITHOUT --cache-to:
podman build --no-cache --layers -t quay.io/jdanek/cache-compression-test:v8 .
podman push quay.io/jdanek/cache-compression-test:v8
crane manifest quay.io/jdanek/cache-compression-test:v8 | jq -r '.layers[].mediaType'

Result: application/vnd.oci.image.layer.v1.tar+zstd ✓ (correct)

  1. Build and push WITH --cache-to:
podman system reset -f
podman build --no-cache --layers --cache-to quay.io/jdanek/cache-compression-test-cache-v6 -t quay.io/jdanek/cache-compression-test:v7 .
podman push quay.io/jdanek/cache-compression-test:v7
crane manifest quay.io/jdanek/cache-compression-test:v7 | jq -r '.layers[].mediaType'

Result: application/vnd.oci.image.layer.v1.tar+gzip ✗ (should be zstd)

The cache also uses gzip:

crane manifest quay.io/jdanek/cache-compression-test-cache-v6:077cd4b1a9a353fc2e41beb42b498264aef7287aed9675da9899238a4ddec6cc | jq -r '.layers[].mediaType'

Result: application/vnd.oci.image.layer.v1.tar+gzip

Expected Behavior

Both cache and final image should use zstd:chunked compression as specified in containers.conf, regardless of whether --cache-to is used.

Actual Behavior

Scenario Cache Final Image
Build with --layers (no cache-to) N/A zstd
Build with --layers --cache-to gzip gzip

The --cache-to flag causes the entire compression_format setting to be ignored.

Environment

podman version 5.7.1
macOS with podman machine (Fedora CoreOS VM)

containers.conf location

/etc/containers/containers.conf in the podman machine VM

Related Issues

Test Images

The test images are publicly available for verification:

  • Cache: quay.io/jdanek/cache-compression-test-cache-v6
  • Final (with cache-to, gzip): quay.io/jdanek/cache-compression-test:v7
  • Final (without cache-to, zstd): quay.io/jdanek/cache-compression-test:v8

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