Search code examples
.netdockerfilecontainersamazon-linux-2023

Installing dotnet8 on amazonlinux 2023 image through dockerfile


I am trying to install dotnet8 on amazon linux 2023 image public.ecr.aws/amazonlinux/amazonlinux:2023. After installing, one of the command that it tries to run is 'dotnet', but it errors out saying:

/bin/sh: line 1: dotnet: command not found

Below is the block of code that i am running to install dotnet:

FROM public.ecr.aws/amazonlinux/amazonlinux:2023

RUN curl -fSL --output dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-arm64.tar.gz \
&& echo "dotnet.tar.gz" \
&& mkdir -p /usr/share/dotnet \
&& tar -oxzf dotnet.tar.gz -C /usr/share/dotnet ./packs ./sdk ./sdk-manifests ./templates ./LICENSE.txt ./ThirdPartyNotices.txt \
&& rm dotnet.tar.gz \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
# Trigger first run experience by running arbitrary cmd
&& dotnet help

But when i loginto the container through docker run command and check for dotnet info I get below details:

bash-5.2# dotnet --info .NET SDK: Version: 8.0.203 Commit: 5e1ceea679 Workload version: 8.0.200-manifests.4e94be9c

Runtime Environment: OS Name: amzn OS Version: 2023 OS Platform: Linux RID: linux-arm64 Base Path:
/var/lang/bin/sdk/8.0.203/

.NET workloads installed: There are no installed workloads to display.

Host: Version: 8.0.3 Architecture: arm64 Commit:
9f4b1f5d66

.NET SDKs installed: 8.0.203 [/var/lang/bin/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 8.0.3 [/var/lang/bin/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.3 [/var/lang/bin/shared/Microsoft.NETCore.App]

Other architectures found: None

Environment variables: DOTNET_ROOT [/var/lang/bin]

global.json file: Not found

Learn more: https://aka.ms/dotnet/info

Download .NET: https://aka.ms/dotnet/download

Not sure what is missing in the dockerfile. Any help/input would be greatly appreciated. Thanks


Solution

  • I was unzipping specific packages into the folder /usr/share/dotnet, instead i unzipped all the files and folders to /usr/share/dotnet with the symlink to /usr/bin/dotnet. It ran successfully.