Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is docker not completely deleting my file?

Tags:

docker

centos

I am trying to build using:

FROM mcr.microsoft.com/dotnet/core/sdk:2.1 AS builder

COPY pythonnet/src/ pythonnet/src
WORKDIR /pythonnet/src/runtime
RUN dotnet build -f netstandard2.0 -p:DefineConstants=\"MONO_LINUX\;XPLAT\;PYTHON3\;PYTHON37\;UCS4\;NETSTANDARD\" Python.Runtime.15.csproj

# copy myApp csproj and restore
COPY src/myApp/*.csproj /src/myApp/
WORKDIR /src/myApp
RUN dotnet restore

# now copy everything else as separate docker step
# (copy to staging folder, remove csproj, and copy down - so we don't overwrite project above)
WORKDIR /
COPY src/myApp/ ./staging/src/myApp
RUN rm ./staging/src/myApp/*.csproj \
    && cp -r ./staging/* ./ \
    && rm -rf ./staging

This was working fine, and in Windows 10 still does, but in CentOS 7 I get:

Step 10/40 : RUN rm ./staging/src/myApp/*.csproj  && cp -r ./staging/* ./ && rm -rf ./staging
 ---> Running in 6b17ae0fae89
cp: cannot stat './staging/src/myApp/myApp.csproj': No such file or directory

Using ls instead of cp throws a similar file not found error, so it looks like Docker still knows about myApp.csproj but cannot see it since it has been removed.

Is there a way around this? I have tried using rsync but similar problems.

like image 965
schoon Avatar asked Nov 06 '22 06:11

schoon


1 Answers

I simply ignored the issue by tacking on ;exit 0 on the offending lines. Not great, but does the job.

EDIT: This worked for me as I cannot upgrade the version of CemtOS. If you can, check out Alexander Block's answer.

like image 147
schoon Avatar answered Nov 15 '22 07:11

schoon