Enable using docker build `--platform` switch (easily)
See original GitHub issueThis is a specific aspect of: https://github.com/dotnet/dotnet-docker/issues/4388
We constructed a “hero Dockerfile” that we want to offer users, but it doesn’t work, sadly. There are multiple points of incompatibility that we need to resolve. See the other issue for more context.
For the SDK/CLI, it comes down to Docker’s and .NET’s syntax/symbols for architecture not matching.
Docker archs:
amd64
arm64
arm
.NET RID archs:
x64
arm64
arm
The archs mostly match across the two systems, except for the first one. We need the RID in -r linux/am64
to be translated to linux/x64
. No other change is needed (at least that we’ve discovered).
We only need this for Linux, for two reasons:
- The ENVs we are using are only offered via Linux and buildkit. Windows doesn’t use buildkit.
- Cross-architecture docker isn’t yet a scenario for Windows containers.
Issue Analytics
- State:
- Created 7 months ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Enable using docker build --platform switch (easily) #4388
There is no way to write a Dockerfile for .NET that is (A) succinct, (B) easy to build from the command line, (C)...
Read more >Faster Multi-Platform Builds: Dockerfile Cross-Compilation ...
In this post, I'll show some patterns that you can use if you want to get the best performance out of such builds....
Read more >Multi-platform
The easiest way to get started with building for multiple platforms is using emulation. With emulation, you can build your app to multiple...
Read more >Multi-Platform Docker Builds
By default, the Docker images we create run on the linux/amd64 platform. ... With the recent buildx work, it's easier than ever to...
Read more >docker build
The docker build command builds Docker images from a Dockerfile and a "context". A build's context is the set of files located in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think the amount of work difference for
-r
and-a
is pretty negligible, so we should go ahead and do both. There’s already an UX inconsistency between CLI options and MSBuild Properties forRuntimeIdentifier
so I’d prefer to make sure the CLI options behave as uniformly as possible.I was just playing with this and realized that
-a
doesn’t work withdotnet restore
.I’d love for
-a
to be our guidance for Dockerfiles, however, we’d need that to work fordotnet restore
.