Dockerfile - 将文件复制到图像

Dockerfile - copy file to image

我尝试将文件 libwiringPi.so.2.52 从主机目录复制到 Ubuntu 20.10 x64 上的 Docker 图像。

FROM mcr.microsoft.com/dotnet/aspnet:3.1.21-alpine3.14-arm64v8 AS base
WORKDIR /app

USER root

COPY "libwiringPi.so.2.52", "./"

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY ["RPI_GPIO_Tests.csproj", "./"]
RUN dotnet restore "RPI_GPIO_Tests.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "RPI_GPIO_Tests.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "RPI_GPIO_Tests.csproj" -c Release -o /app/publish

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

文件 libwiringPi.so.2.52Dockerfile

位于同一位置

我需要它在容器内 /app 文件夹中的 .dll 个文件中。

不幸的是我收到消息: COPY failed: file not found in build context or excluded by .dockerignore: stat libwiringPi.so.2.52,: file does not exist

.dockerignore 文件只是:

bin/
obj/

它是 COPY 语句中两个文件名之间的逗号。

将语句更改为

COPY "libwiringPi.so.2.52" "./"