Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The specified RuntimeIdentifier 'linux-linux/amd64' is not recognized #31616

Closed
adamlonsdale opened this issue Apr 4, 2023 · 9 comments
Closed
Labels
untriaged Request triage from a team member

Comments

@adamlonsdale
Copy link

adamlonsdale commented Apr 4, 2023

Describe the bug

When building an amd64 container on an arm64 device (MacBook Pro M2) I hit the problem with dotnet restore hanging forever. I mitigated this by using the BUILDPLATFORM env variable in tandem with the 8.0 nightly preview SDK.

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/nightly/sdk:8.0-preview as build-env

This worked well 9 days ago but seemingly running the same command now seems to suggest it's trying to restore a linux-linux/arm64 RID which won't exist.

To Reproduce

docker buildx build --platform linux/arm64,linux/amd64 --output "type=image,push=true" --no-cache --file ./Dockerfile . --compress --tag "REDACTED"

I have the relevant portion of my Dockerfile below

RUN echo "I am running on ${BUILDPLATFORM}"
RUN echo "building for ${TARGETPLATFORM}"
RUN export TARGETPLATFORM="${TARGETPLATFORM}"

RUN dotnet restore -a $TARGETPLATFORM

which outputs

 => [linux/arm64 build-env 5/9] RUN echo "I am running on linux/arm64"                                                                                                                             0.2s
 => [linux/arm64->amd64 build-env 5/9] RUN echo "I am running on linux/arm64"                                                                                                                      0.2s
 => [linux/arm64->amd64 build-env 6/9] RUN echo "building for linux/amd64"                                                                                                                         0.0s
 => [linux/arm64 build-env 6/9] RUN echo "building for linux/arm64"                                                                                                                                0.1s
 => [linux/arm64->amd64 build-env 7/9] RUN export TARGETPLATFORM="linux/amd64"                                                                                                                     0.1s
 => [linux/arm64 build-env 7/9] RUN export TARGETPLATFORM="linux/arm64"                                                                                                                            0.0s
 => ERROR [linux/arm64 build-env 8/9] RUN dotnet restore -a linux/arm64                                                                                                                            1.4s
 => ERROR [linux/arm64->amd64 build-env 8/9] RUN dotnet restore -a linux/amd64       

Exceptions (if any)

The specified RuntimeIdentifier 'linux-linux/amd64' is not recognized

Further technical details

  • Include the output of dotnet --info
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Request triage from a team member label Apr 4, 2023
@baronfel
Copy link
Member

baronfel commented Apr 4, 2023

@JL03-Yue can you take a look here? This looks related to the golang-style platform work we did recently.

@adamlonsdale
Copy link
Author

I did see a PR by @JL03-Yue from 26th Feb I believe that may have affected this behaviour but I assumed that it would have been in the nightly build 9 days ago, but I'd love to understand more.

@JL03-Yue
Copy link
Member

JL03-Yue commented Apr 5, 2023

Yes, will look into this

@JL03-Yue
Copy link
Member

JL03-Yue commented Apr 6, 2023

@adamlonsdale For the -a or --arch option, it recognizes the architecture. For --os option, it recognizes the operating system. For the -r or --runtime option, it recognizes the [os]/[arch] and parse later. Instead of RUN dotnet restore -a $TARGETPLATFORM, I think it might be RUN dotnet restore -r $TARGETPLATFORM

@adamlonsdale
Copy link
Author

Thanks for the response, I tried the -r flag on the latest nightly SDK but it suggests the RID is not found, I presume this is because docker passes linux/amd64 when the RID would be linux-x64. My understanding that the architecture is arm64 so -a would be correct?

[build-env 8/9] RUN dotnet restore -r linux/amd64:
#15 1.384 Determining projects to restore...
#15 1.461 /usr/share/dotnet/sdk/8.0.100-preview.3.23178.7/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error NETSDK1083: The specified RuntimeIdentifier 'linux/amd64' is not recognized.

@JL03-Yue
Copy link
Member

I think it might be RUN dotnet restore -a $TARGETARCH

Refer to dotnet/dotnet-docker#4388 @richlander @baronfel

@richlander
Copy link
Member

richlander commented Apr 10, 2023

I just tested it. It works for me, on both x64 and Arm64 (with --platform amd64). Can you try this:

$ pwd
/home/rich/git/dotnet-docker/samples/aspnetapp
$ docker build --pull -t aspnetapp --platform amd64 -f Dockerfile.alpine-non-root .

Please clone the repo and build from this directory to validate: https://github.com/dotnet/dotnet-docker/tree/main/samples/aspnetapp

What I see:

$ docker build --pull -t aspnetapp --platform amd64 -f Dockerfile.alpine-non-root .
[+] Building 10.3s (15/15) FINISHED
 => [internal] load build definition from Dockerfile.alpine-non-root                                               0.0s
 => => transferring dockerfile: 54B                                                                                0.0s
 => [internal] load .dockerignore                                                                                  0.0s
 => => transferring context: 34B                                                                                   0.0s
 => [internal] load metadata for mcr.microsoft.com/dotnet/nightly/aspnet:8.0-preview-alpine                        0.9s
 => [internal] load metadata for mcr.microsoft.com/dotnet/nightly/sdk:8.0-preview-alpine                           0.2s
 => [build 1/6] FROM mcr.microsoft.com/dotnet/nightly/sdk:8.0-preview-alpine@sha256:75a196c1a3484d1d937eb07efb8c0  0.0s
 => [internal] load build context                                                                                  0.0s
 => => transferring context: 6.79kB                                                                                0.0s
 => [stage-1 1/3] FROM mcr.microsoft.com/dotnet/nightly/aspnet:8.0-preview-alpine@sha256:33db03d4f1828a99a0711ecb  0.1s
 => => resolve mcr.microsoft.com/dotnet/nightly/aspnet:8.0-preview-alpine@sha256:33db03d4f1828a99a0711ecb3c403c81  0.0s
 => => sha256:33db03d4f1828a99a0711ecb3c403c81390d85ef34987e35ce8289ef2f44633d 1.11kB / 1.11kB                     0.0s
 => => sha256:382c700816424f91113d9043c82ee1c6aeeb67dae9370d3279b6fa38b5c70997 1.37kB / 1.37kB                     0.0s
 => => sha256:37c042de115a31844c5eeeca9f31619db70727f7cefb8854afd5fe3fc9eaff4c 4.90kB / 4.90kB                     0.0s
 => CACHED [build 2/6] WORKDIR /source                                                                             0.0s
 => CACHED [build 3/6] COPY aspnetapp/*.csproj .                                                                   0.0s
 => [build 4/6] RUN dotnet restore -a amd64                                                                        3.8s
 => [stage-1 2/3] WORKDIR /app                                                                                     0.0s
 => [build 5/6] COPY aspnetapp/. .                                                                                 0.1s
 => [build 6/6] RUN dotnet publish -a amd64 --no-restore -o /app                                                   5.1s
 => [stage-1 3/3] COPY --from=build /app .                                                                         0.1s
 => exporting to image                                                                                             0.1s
 => => exporting layers                                                                                            0.1s
 => => writing image sha256:a696bf37b41ca95dcfdf2f4ec85430b25cedf2e8ddf51470b85b1bc51bb1c46c                       0.0s
 => => naming to docker.io/library/aspnetapp                                                                       0.0s
$ docker inspect aspnetapp -f "{{.Os}}\{{.Architecture}}"
linux\amd64

@adamlonsdale
Copy link
Author

hello, I can confirm that on Preview 3 when changing TARGETARCH it does indeed resolve the issue and build the container. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

4 participants