Docker Community Forums

Share and learn in the Docker community.

Where is the executable file in container?

Hi!

I have next dockerfile:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 as builder
WORKDIR /src
COPY ./Sources /src
RUN dotnet publish ./MyApp/MyApp.csproj -o /publish

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 as runtime
WORKDIR /host
COPY --from=builder /publish /host
ENTRYPOINT dotnet MyApp.dll

If I run container:
docker build -t my-app .
docker run --name my-app-container my-app
all works fine.

As an experiment, I want to launch the container without launching the application and launch the application there manually:
docker run --name my-app-container -it --entrypoint "/bin/bash" my-app

An invitation appears, I am writing:
dotnet MyApp.dll

Response:

bash: dotnet: command not found

Why doesn’t it find dotnet if everything in ENTRYPOINT in the dockerfile starts up normally?

The question is still actual.

Your server and your container have different filesystems, unless you specify otherwise mounting a server folder on a container folder with --volume command.

Here you expect your container to know about docker.groovy file juste because you run the command in the server folder containing the file.

One way to do this would be to start a container with your current server folder mounted in a random in your container, and run the groovy script as an entrypoint. Something like this (untested)

docker run -v .:/random groovy_repo_1 /random/docker.groovy

Sorry, but I don’t understand how mounting will help me. I expect the dotnet file is present in the container, because otherwise the ENTRYPOINT dotnet MyApp.dll command would not succeed. dotnet is not a local file on the server, it is part of the image mcr.microsoft.com/dotnet/core/aspnet:3.1.