构建Azure DevOps代理Docker镜像时无法定位dotnet-sdk-7.0包
问题:M1 Mac构建Azure DevOps自托管代理镜像时无法安装dotnet-sdk-7.0
背景
我正在创建适配Azure Container Apps的Azure DevOps自托管代理Docker镜像,要求镜像内置dotnet-sdk-7.0,且以非root用户运行(因Azure Container Apps存在无root权限限制)。
我的Dockerfile内容
FROM ubuntu:20.04 LABEL Author="Moim Hossain" LABEL Email="moimhossain@gmail.com" 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" ]
构建报错信息
在M1芯片的Mac上构建时,其他步骤正常,但安装dotnet-sdk-7.0环节出现如下报错:
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'
我的怀疑
我怀疑问题与执行apt-get install -y dotnet-sdk-7.0命令的用户权限有关。
内容的提问来源于stack exchange,提问作者Rob Bowman
相关产品推荐
相关产品推荐

