Skip to content

Support zstd compression for oci/docker image layers #52244

Open

Description

@Kieranties

Is your feature request related to a problem? Please describe.

I am currently updating my build tooling to use the dotnet SDK to build and publish containers. So far this has been excellent and easy to use.

Docker recently announced that their hardened images are now free. I attempted to use the hardened image by setting the ContainerBaseImage property in my csproj

<Project>
  <PropertyGroup>
    <!-- ... snip -->
    <ContainerBaseImage>dhi.io/dotnet:8-alpine3.22</ContainerBaseImage>
  </PropertyGroup>
</Project>

However, when my publish has ran I get the following error:

Products.EventsListener.Service net8.0 failed with 1 error(s) (2.7s)
    C:\Program Files\dotnet\sdk\10.0.101\Containers\build\Microsoft.NET.Build.Containers.targets(261,5): error CONTAINER2001: Unrecognized mediaType 'application/vnd.oci.image.layer.v1.tar+zstd'.

After reviewing the code base I found the SchemaTypes class does not have the given media type - and can see two locations in code where this can cause the error to be thrown

Describe the solution you'd like

To have support added for the application/vnd.oci.image.layer.v1.tar+zstd media type so that the hardened images can be used within the container build features of the SDK.

Additional context

  • Despite targeting a net8 build I am using the 10.0.100 sdk

Activity

  1. added
    untriaged
    on Dec 18, 2025
  2. added
    Area-Containers
    on Dec 18, 2025
  3. baronfel commented on Dec 18, 2025

    @baronfel
    Member

    Thanks for reporting - the underlying request here is for us to support zstd compression, so we'll have to check if this is something the Runtime supports yet. EDIT: It doesn't, I've linked this request to that issue for tracking.

  4. changed the title [-]Support latest media types for oci/docker builds[/-] [+]Support zstd compression for oci/docker image layers[/+] on Dec 18, 2025
  5. added
    Blocked
    on Dec 18, 2025
  6. removed
    Blocked
    untriaged
    on Dec 18, 2025
  7. baronfel commented on Dec 19, 2025

    @baronfel
    Member

    There's another path we could go down here - we don't actually need to be able to decompress/compress the zstd layers, we only need to be able to download them and potentially push them elsewhere. We may be able to 'support' the consumption of zstd images just by treating the layers as opaque blobs.

    The only compression mode we'd support for the layers we create for apps would be GZip, but since it's possible to mix and match layer media types this shouldn't be a problem at all.

  8. neersighted commented on Dec 19, 2025

    @neersighted

    @baronfel That is the approach I would suggest as a container ecosystem contributor/maintainer; there is nothing wrong with mixing-and-matching (though I'd encourage picking one of OCI or Docker mediaTypes for a given manifest; technically you can mix and match those too, but some tools don't handle it gracefully) mediaTypes.

  9. baronfel commented on Dec 19, 2025

    @baronfel
    Member

    Thanks for the validation @neersighted ! I've got a copilot PR out for this now that should have us compatible soon :)

    though I'd encourage picking one of OCI or Docker mediaTypes

    We definitely need to do some consolidation here - I think we've got an issue tracking the is already, but if not I'll get one created.

  10. Falco20019 commented on Sep 8, 2026

    @Falco20019

    Any progress? I ran into this with <ContainerBaseImage>dhi.io/aspnetcore:10.0</ContainerBaseImage>. Strangely it works on our CI (linux/amd64) and fails locally (darwin/arm64) although both use application/vnd.oci.image.layer.v1.tar+zstd according to the platform manifests.

    We use Aspire with AddProject so using a Dockerfile as alternative would technically be possible with DHI but would also mean that for publishing we need to use AddDockerfile instead.

  11. ScottRosenberg2 commented on Oct 20, 2026

    @ScottRosenberg2

    Dotnet 11 adds support for zstd, so maybe this should be re-evaluated for 11.

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

    Area-Containers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions