-1

Tried lots of searches for this and am drawing a blank.

I have a docker file that isn't building. I'd like to do something like: RUN echo $(ls *) and see what exactly is in my current directory. Cause I feel like something is missing as I'm getting weird errors when I run my dotnet restore command. When I run said command locally the command works just fine. And the same command works for other dockerfiles in other projects.

How can I see what the content of my docker image is while it is being build?

Edit: Adding Dockerfile:

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
#FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base

ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS build
#FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS build

ARG FEED_ACCESSTOKEN
ARG version

ENV USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER=false
ENV NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED true
ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS \
    "{\"endpointCredentials\": [{\"endpoint\":\"https://pkgs.dev.azure.com/<CompanyNameHere>/_packaging/<CompanyNameHere>/nuget/v3/index.json\", \"username\":\"docker\", \"password\":\"${FEED_ACCESSTOKEN}\"}]}"

RUN curl -L https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh  | bash
RUN echo "${FEED_ACCESSTOKEN}"

WORKDIR /src

COPY NuGet.Config . 
COPY src/AppPortal.Web/*.csproj AppPortal.Web/

RUN dotnet restore AppPortal.Web/AppPortal.Web.csproj --configfile NuGet.Config

COPY src/ .

# Remove any appsettings (except appsettings.json) so they do not get bundled in the docker image
RUN  find . -type f -name appsettings.*.json -exec rm {} \;

WORKDIR /src/AppPortal.Web
RUN dotnet build "AppPortal.Web.csproj" -c Release --no-restore

FROM build AS publish

WORKDIR /src/AppPortal.Web

RUN dotnet publish "AppPortal.Web.csproj" -c Release -o /app --no-build

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

Error Message:

Removing intermediate container 9dfae1c6d08b
 ---> 48358f7e2161
Step 21/35 : RUN dotnet restore AppPortal.Web/AppPortal.Web.csproj --configfile NuGet.Config
 ---> Running in b4e6724f09d9
  It was not possible to find any installed .NET Core SDKs
  Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
      https://aka.ms/dotnet-download
The command '/bin/sh -c dotnet restore AppPortal.Web/AppPortal.Web.csproj --configfile NuGet.Config' returned a non-zero code: 145

Running the same dotnet restore command locally works just fine.

Curtis
  • 1
  • 3
  • There is always the option to just start the base image and executes the command - one after another - as the dockerfile would (in reality, this is what docker does to create an image). – Turing85 Jul 31 '23 at 16:48
  • 1
    Please provide your dockerfile so we can help a bit more, getting `nonsensical errors` dose not mean anything. – George Jul 31 '23 at 16:52
  • Thanks for the feedback. Added the Dockerfile and the error. Frustrated with this one as I have a dozen other inherited projects that work just fine. But this particular one gives me an error that doesn't make any sense to me. – Curtis Jul 31 '23 at 19:01
  • Ok, in going cross eyed comparing with another working dockerfile I realized that I have aspnet:3.1 for the AS Build. And what it actually should be is sdk:3.1 My question was originally intended to be more of a "How do I output the contents of a command like RUN echo $(ls *)" so that I can see the outputs of my folders. I had another project that for some odd reason required me to add application/... in front of everything. Even though it should be the same as all the others. – Curtis Jul 31 '23 at 19:14
  • It looks like you're using the "classic" builder and not BuildKit, so you should see the output of all `RUN` commands, like what you show in the final output. (Compare [Why is docker build not showing any output from commands?](https://stackoverflow.com/questions/64804749/why-is-docker-build-not-showing-any-output-from-commands) if you were using BuildKit.) Just `RUN ls`: both `echo $(command)` and `ls *` add unnecessary wrappers and expansions you don't need. – David Maze Aug 01 '23 at 12:30
  • I'm using whatever latest docker is as of a month ago. From that link you shared, the --progress=plain option worked for me. Also thanks for helping me simplify my docker command. – Curtis Aug 01 '23 at 12:58

1 Answers1

0

@David Maze helped me find the answer:

I needed to add --progress=plain / EXPORT BUILDKIT_PROGRESS=plain to my docker command / file.

Greatly appreciate the help!

Curtis
  • 1
  • 3