0

I'm following this docker tutorial for aspnet core. I built 1 aspnet core template project with swagger and it works fine. I have a problem with the docker file they instruct. Can someone help me.Tks.

Docs:https://docs.docker.com/samples/dotnetcore/

My repository : https://github.com/ThanhDeveloper/WebApplicationAspNetCoreTemplate/tree/DockerIntegration

Error when run command docker build -t abc .

I tried to change engine/examples with ../AspNetCoreTemplate ./ or ./AspNetCoreTemplate ./ but it didn't fix the error

nguyenthanh@MacBook-Pro-cua-Nguyen AspNetCoreTemplate % docker build -t abc .
[+] Building 0.4s (12/14)                                                                                                                        
 => [internal] load build definition from Dockerfile                                                                                        0.0s
 => => transferring dockerfile: 477B                                                                                                        0.0s
 => [internal] load .dockerignore                                                                                                           0.0s
 => => transferring context: 34B                                                                                                            0.0s
 => [internal] load metadata for mcr.microsoft.com/dotnet/aspnet:5.0                                                                        0.3s
 => [internal] load metadata for mcr.microsoft.com/dotnet/sdk:5.0                                                                           0.3s
 => [build-env 1/6] FROM mcr.microsoft.com/dotnet/sdk:5.0@sha256:3ca1a372ff025d1f84bb2bef7dbb7c284ea3b49e00bcd0047336b9bca9f8dfb7           0.0s
 => [stage-1 1/3] FROM mcr.microsoft.com/dotnet/aspnet:5.0@sha256:ca2e100d2c30490f7cb34ab737bc33e9bd7e533446f6c3356c082caccae7be1a          0.0s
 => [internal] load build context                                                                                                           0.0s
 => => transferring context: 47B                                                                                                            0.0s
 => CACHED [build-env 2/6] WORKDIR /app                                                                                                     0.0s
 => CACHED [stage-1 2/3] WORKDIR /app                                                                                                       0.0s
 => CANCELED [build-env 3/6] COPY *.csproj ./                                                                                               0.0s
 => CACHED [build-env 4/6] RUN dotnet restore                                                                                               0.0s
 => ERROR [build-env 5/6] COPY ../engine/examples ./                                                                                        0.0s
------
 > [build-env 5/6] COPY ../engine/examples ./:
------
failed to compute cache key: "/engine/examples" not found: not found

1 Answer 1

1

You cannot copy from outside the build context. So COPY ../engine/examples ./ is failing because docker cannot traverse the ../ to go up a level.

All files you want to copy must be accessible from the within the docker context (. in this case)

Sign up to request clarification or add additional context in comments.

1 Comment

Tks for your reply. I tried with COPY ./ ./ and it is working for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.