docker打包镜像bug记录

文章讲述了在使用Dockerfile构建.NETCore应用时遇到的问题,包括Docker引擎找不到build层,源列表配置错误,以及因误操作导致的项目文件查找失败。作者详细描述了问题及其解决方法。
摘要由CSDN通过智能技术生成

项目场景:

Dockerfile:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS base
RUN echo "Asia/Shanghai" > /etc/timezone && \
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
    sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@/g /etc/apt/sources.list && \
    apt update && \
    apt install -y curl && \
    apt clean && \
    rm -rf /var/lib/apt/lists/*  

HEALTHCHECK --interval=1m --retries=3 --timeout=20s CMD \
    curl -f -s http://127.0.0.1:8080/api/Healthy/Test
WORKDIR /app
EXPOSE 8080

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS base
WORKDIR /app
RUN ls -l && pwd
COPY BenanUtilities.Jiabao.TestTool.TestServer.sln .
COPY BenanUtilities.Jiabao.TestTool.TestServer.csproj .
RUN dotnet restore
COPY . .
RUN dotnet build

FROM build AS publish
RUN dotnet publish -c Release -o ./publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "test-server.dll"]

问题1:

docker引擎找不到build,

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS base   

将build写成了base。

问题2:

 仔细检查,发现

sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@/g /etc/apt/sources.list

 该位置多写了一个斜杠。

问题3:

error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.

 由于在脚本文件里错写了一句“cd publish”, 导致找不到sln或csproj文件,触发此错误。

  • 11
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值