I’m trying to follow the guidance from this blog post
I need the docker image to have the dotnet sdk installed. It’s also got to run in Azure Container Apps, which has a limitation that is can’t have root access.
My Dockerfile is as follows:
FROM ubuntu:20.04
LABEL Author="Moim Hossain"
LABEL Email="[email protected]"
LABEL GitHub="https://github.com/moimhossain"
LABEL BaseImage="ubuntu:20.04"
RUN DEBIAN_FRONTEND=noninteractive apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && useradd -m agentuser
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends
apt-transport-https
apt-utils
ca-certificates
curl
git
iputils-ping
jq
lsb-release
software-properties-common
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash
# Can be 'linux-x64', 'linux-arm64', 'linux-arm', 'rhel.6-x64'.
ENV TARGETARCH=linux-x64
WORKDIR /azp
RUN chown -R agentuser:agentuser /azp
RUN chmod 755 /azp
# Install dependencies
RUN apt-get update &&
apt-get install -y
wget
apt-transport-https
ca-certificates
curl
software-properties-common
# Install .NET Core SDK
RUN wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb &&
dpkg -i packages-microsoft-prod.deb &&
apt-get update &&
apt-get install -y dotnet-sdk-7.0
COPY ./start.sh .
RUN chmod +x start.sh
# All subsequent commands run under this user
USER agentuser
ENTRYPOINT [ "./start.sh", "--once" ]
When I run this on my mac (m1 cpu), it seems to work fine until it gets to the point where it’s trying to add dotnet. This is the end of the output:
13 1.272 Get:10 https://packages.microsoft.com/ubuntu/20.04/prod focal/main all Packages [2521 B]
#13 1.298 Fetched 504 kB in 1s (952 kB/s)
#13 1.298 Reading package lists...
#13 1.912 Reading package lists...
#13 2.361 Building dependency tree...
#13 2.446 Reading state information...
#13 2.477 E: Unable to locate package dotnet-sdk-7.0
#13 2.477 E: Couldn't find any package by glob 'dotnet-sdk-7.0'
#13 2.477 E: Couldn't find any package by regex 'dotnet-sdk-7.0'
I suspect the problem relates to permission of the user running the command apt-get install -y dotnet-sdk-7.0?
2
Answers
To simplify your custom image creation process you can start directly from the images provided out of the box by Microsoft with the already installed SDK:
mcr.microsoft.com/dotnet/sdk:7.0
.On Docker Hub you can find all the Microsoft .NET ready to use images with runtimes and SDK.
Rob, I have tried the dockerfile you provided, and it works/creates docker image.
Here’s the GitHub repo and action that builds the image from the same Dockerfile as you provided above.
https://github.com/MoimHossain/StackOverflow-76660978/actions/runs/5527830727/jobs/10083988499#step:3:1264