我是Azure DevOps的新手,正在尝试构建我的第一个完整管道,但是在构建docker映像时遇到了问题。
来自Docker文件的一行使管道失败,带有apt-get的管道!
您有解决此问题的想法吗?
这是我遇到的错误(日志):
Step 11/25 : RUN apt-get update && apt-get install -y libgdiplus libc6-dev && dotnet dev-certs https; dotnet publish --self-contained --runtime linux-x64 -c Debug -o out src/${PROJECT};
---> Running in 29ada69fe569
'apt-get' is not recognized as an internal or external command,
operable program or batch file.
The command 'cmd /S /C apt-get update && apt-get install -y libgdiplus libc6-dev && dotnet dev-certs https; dotnet publish --self-contained --runtime linux-x64 -c Debug -o out src/${PROJECT};' returned a non-zero code: 1
'displayName:' is not recognized as an internal or external command,
operable program or batch file.
'failOnStderr:' is not recognized as an internal or external command,
operable program or batch file.
##[error]Cmd.exe exited with code '1'.
这是我的管道文件:
- script: |
docker image build --no-cache --tag=registry.gitlab.com/iznogood/myproject/iznogood.myproject.httpapi:1.0.0 -f .\src\Iznogood.Myproject\Dockerfile .
displayName: 'Build image'
failOnStderr: true
这是Docker文件:
### >>> GLOBALS
ARG ENVIRONMENT="Production"
ARG PROJECT="Iznogood.MyProject.HttpApi"
### <<<
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
### >>> IMPORTS
ARG ENVIRONMENT
ARG PROJECT
### <<<
ARG NUGET_CACHE=https://api.nuget.org/v3/index.json
ARG NUGET_FEED=https://api.nuget.org/v3/index.json
# Copy sources
COPY src/ /app/src
ADD common.props /app
WORKDIR /app
RUN apt-get update && apt-get install -y libgdiplus libc6-dev && dotnet dev-certs https; \
dotnet publish --self-contained --runtime linux-x64 -c Debug -o out src/${PROJECT};
# Start a new image from aspnet runtime image
#FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS runtime
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS runtime
### >>> IMPORTS
ARG ENVIRONMENT
ARG PROJECT
### <<<
ENV ASPNETCORE_ENVIRONMENT=${ENVIRONMENT}
ENV ASPNETCORE_URLS="http://+:80;https://+:443;https://+:44359"
#ENV ASPNETCORE_URLS="http://+:80"
ENV PROJECT="${PROJECT}.dll"
# Make logs a volume for persistence
VOLUME /app/Logs
# App directory
WORKDIR /app
# Copy our build from the previous stage in /app
COPY --from=build /app/out ./
RUN apt-get update && apt-get install -y ffmpeg libgdiplus libc6-dev
# Ports
EXPOSE 80
EXPOSE 443
EXPOSE 44359
ENTRYPOINT dotnet ${PROJECT}
答案 0 :(得分:1)
检查管道并验证您所运行的操作系统。如果它是Windows映像,则apt-get
无法正常工作。更改管道以使用Linux计算机。
答案 1 :(得分:0)
您可以添加后缀以指定所需的计算机吗?
对于debian buster:FROM mcr.microsoft.com/dotnet/core/sdk:3.1.201-buster AS build
在“完整标签列表”部分中建立的标签: Docker Hub Repo