testcontainers-dotnet icon indicating copy to clipboard operation
testcontainers-dotnet copied to clipboard

[Enhancement]: Support customizing image pull behavior to include a "platform" override

Open jbogard opened this issue 1 month ago • 2 comments

Problem

This is a copy of this issue in the Java repo: https://github.com/testcontainers/testcontainers-java/issues/9908

Solution

Have some sort of WithPlatform configuration option

Benefit

Have consistent images pulled for teams with different architectures (ARM64/AMD64 etc). Some images rightfully do not have an ARM64 architecture available and these just don't work at all on ARM-based machines like Macs/MacBook Pros

Alternatives

None, it doesn't work. I have to disable those tests on my M4 MBP

Would you like to help contributing this enhancement?

Yes

jbogard avatar Nov 24 '25 21:11 jbogard

Thanks for creating the issue. I remember another user reporting something similar (https://github.com/testcontainers/testcontainers-dotnet/issues/1471#issuecomment-3001819304), but I lost track of it because the issue was closed after we added Kraft support to the library, and then I went on vacation. I agree, this is definitely something we need to address and support.

Edit: I believe you can work around the issue by pulling the image manually. It's not convenient, but it should work until the library supports it.

From the issue and discussion, it looks like another workaround is to use the digest.

HofmeisterAn avatar Nov 25 '25 05:11 HofmeisterAn

the java team have not decided to implement this - I have simply extracted the issue for better visibility of the decision. but the team has explicitly NOT decided yet to implement this. https://github.com/testcontainers/testcontainers-java/issues/9908#issuecomment-2701870687

alexanderankin avatar Nov 25 '25 15:11 alexanderankin

I had the same issue when trying to use the vibs2006/sql_server_fts image (used in PhenX.EntityFrameworkCore.BulkInsert.Tests) which doesn't have support for arm64. The x64 slice still works on ARM-based macs under Rosetta, though.

As @HofmeisterAn mentioned, you can workaround by manually pulling the image:

docker pull vibs2006/sql_server_fts --platform amd64

I have a branch at https://github.com/0xced/testcontainers-dotnet/tree/feature/image-platform that adds support for configuring the platform. This branch is still lacking documentation and tests.

0xced avatar Dec 12 '25 17:12 0xced

@0xced I looked into this a few days ago as well and tried a slightly different approach, but I think using the IImage interface might still be better. Ideally, we extract the platform from the Dockerfile too (the regex should already extract the information), which is necessary to build images properly. WDYT?

HofmeisterAn avatar Dec 12 '25 18:12 HofmeisterAn