Home > database >  Dockerfile - copy file to image
Dockerfile - copy file to image

Time:12-02

I try to copy file libwiringPi.so.2.52 from host directory to Docker image on Ubuntu 20.10 x64.

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"]

File libwiringPi.so.2.52 is in the same location as Dockerfile

enter image description here

and I need it among .dll files in /app folder inside container.

enter image description here

Unfortunately I got message: COPY failed: file not found in build context or excluded by .dockerignore: stat libwiringPi.so.2.52,: file does not exist

.dockerignore file is just:

bin/
obj/

CodePudding user response:

It's the comma between the two filenames in the COPY statement that does it.

Change the statement to

COPY "libwiringPi.so.2.52" "./"
  • Related