question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enable using docker build `--platform` switch (easily)

See original GitHub issue

This 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:closed
  • Created 7 months ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
baronfelcommented, Feb 7, 2023

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 for RuntimeIdentifier so I’d prefer to make sure the CLI options behave as uniformly as possible.

1reaction
richlandercommented, Feb 11, 2023

I was just playing with this and realized that -a doesn’t work with dotnet restore.

I’d love for -a to be our guidance for Dockerfiles, however, we’d need that to work for dotnet restore.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found