0

I'm trying to print the current directory from a dockerfile where I have some COPY statements not finding files.

I tried:

RUN ls
RUN pwd
RUN echo "$PWD"
RUN echo "whatever"

and while the command runs, there is no output in the build log. this is also the solution recommended in Is it possible to show the `WORKDIR` when building a docker image? but in 2021, on MacOS, it doesn't work.

how can I do this?

A practical example:

FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine as build

WORKDIR /src/
COPY x/ ./x
RUN dotnet restore ./x/Common/Common.fsproj
RUN dotnet restore ./x/Exchange/Exchange.fsproj
RUN dotnet restore ./x/Terminal/Terminal.fsproj
RUN dotnet restore ./x/Mathematics/Mathematics.fsproj

COPY Exchanges/Binance ./Exchanges/Binance
RUN dotnet restore ./Exchanges/Binance/Binance.fsproj
RUN echo "$PWD"

and output:

[+] Building 1.4s (18/20)
 => [internal] load build definition from dockerfile                                                                                                                                                                                                     0.0s
 => => transferring dockerfile: 984B                                                                                                                                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                        0.0s
 => => transferring context: 34B                                                                                                                                                                                                                         0.0s
 => [internal] load metadata for mcr.microsoft.com/dotnet/runtime:5.0-alpine                                                                                                                                                                             0.2s
 => [internal] load metadata for mcr.microsoft.com/dotnet/sdk:5.0-alpine                                                                                                                                                                                 0.2s
 => [final 1/3] FROM mcr.microsoft.com/dotnet/runtime:5.0-alpine@sha256:18d4a2d18243db3256ebaaaf3407f1fdce86ed9c2049fbfef9709af6c4f399b4                                                                                                                 0.0s
 => [build  1/11] FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine@sha256:61f489d2a390a9df55c21fff36de4be1f50ce9f53afc97496dbe306b6b286c2e                                                                                                                   0.0s
 => [internal] load build context                                                                                                                                                                                                                        0.0s
 => => transferring context: 7.74kB                                                                                                                                                                                                                      0.0s
 => CACHED [final 2/3] WORKDIR /app                                                                                                                                                                                                                      0.0s
 => CACHED [build  2/11] WORKDIR /src/                                                                                                                                                                                                                   0.0s
 => CACHED [build  3/11] COPY x/ ./x                                                                                                                                                                                                   0.0s
 => CACHED [build  4/11] RUN dotnet restore ./x/Common/Common.fsproj                                                                                                                                                                            0.0s
 => CACHED [build  5/11] RUN dotnet restore ./x/Exchange/Exchange.fsproj                                                                                                                                                                        0.0s
 => CACHED [build  6/11] RUN dotnet restore ./x/Terminal/Terminal.fsproj                                                                                                                                                                        0.0s
 => CACHED [build  7/11] RUN dotnet restore ./x/Mathematics/Mathematics.fsproj                                                                                                                                                                  0.0s
 => CACHED [build  8/11] COPY Exchanges/Binance ./Exchanges/Binance                                                                                                                                                                0.0s
 => CACHED [build  9/11] RUN dotnet restore ./Exchanges/Binance/Binance.fsproj                                                                                                                                                     0.0s
 => [build 10/11] RUN echo "$PWD"                                                                                                                                                                                                                        0.3s
 => ERROR [build 11/11] RUN dotnet restore ./Run/Igo.fsproj                       

it doesn't find the last file and that's why I'm trying to troubleshoot the path. RUN pwd, RUN ls, RUN echo "$pwd" don't output anything

Thomas
  • 10,933
  • 14
  • 65
  • 136

0 Answers0