containerizing an app that I did in the past, I started working on my Mac M1 and created the following Dockerfile (as you'll see, very very simple one):
FROM mcr.microsoft.com/dotnet/sdk:6.0
COPY *.csproj ./
RUN dotnet restore
COPY ../*.cs ./
COPY ../Properties ./
RUN dotnet publish -c Release
FROM mcr.microsoft.com/dotnet/runtime:6.0
COPY ./bin/Release/net6.0/publish app/
WORKDIR /app
ENTRYPOINT ["dotnet", "app.dll"]
Launching the simplest
docker build -t counter-image -f Dockerfile .
It works perfectly in MacM1, fails in Windows 10.
When I run docker build -t counter-image -f Dockerfile .
#1 [internal] load build definition from Dockerfile
#1 sha256:a5c8a0c34c743f255ebdc15d65bfbbe5094a37db3462015427300b5d8afdb80e
#1 transferring dockerfile: 403B done
#1 DONE 0.1s
#2 [internal] load .dockerignore
#2 sha256:dc1169a26a22674179859bc7bb3820723365424bb8804c7917733b3b74ec5d65
#2 transferring context: 2B done
#2 DONE 0.1s
#3 [internal] load metadata for mcr.microsoft.com/dotnet/runtime:6.0
#3 sha256:0128d5218b10a50bf55970db7c113f09503205e2b2ada4931bb5d0c6628fdd2a
#3 DONE 1.2s
#5 [internal] load build context
#5 sha256:0f49ce22f840bcf956513309e49cda3c26b83cb92b6e3f539b463beb14fb36e7
#5 DONE 0.0s
#4 [stage-1 1/3] FROM mcr.microsoft.com/dotnet/runtime:6.0#sha256:dbf2ee47aeb7cc078d1351ef961913296d9044db8928b3d1cbb88d7d3e87cccb
#4 sha256:2aacc73d23873adb384695e176a97f35524a7a10087c170e336161af3a1b4ce3
#4 resolve mcr.microsoft.com/dotnet/runtime:6.0#sha256:dbf2ee47aeb7cc078d1351ef961913296d9044db8928b3d1cbb88d7d3e87cccb
0.1s done
#4 sha256:dbf2ee47aeb7cc078d1351ef961913296d9044db8928b3d1cbb88d7d3e87cccb
2.17kB / 2.17kB done
#4 sha256:b534d6bba13c1654a13497dfcb04ad0b398772b5d1da0e5bec5e0a3e38e15ccb
1.16kB / 1.16kB done
#4 sha256:8b872fde0fc7d2e58dd4f04ad53f21d27043640978dd7730add604f9b58ed207
2.80kB / 2.80kB done
#4 CANCELED
#5 [internal] load build context
#5 sha256:0f49ce22f840bcf956513309e49cda3c26b83cb92b6e3f539b463beb14fb36e7
#5 transferring context: 25B done
#5 DONE 0.1s
#6 [stage-1 2/3] COPY ./bin/Release/net6.0/publish MindsphereConfigurationMover/
#6 sha256:434ed7ed1150d04fac20d05feeb2d63aa5bdcf9cf63821709aa8091d48422119
#6 ERROR: "/bin/Release/net6.0/publish" not found: not found
[stage-1 2/3] COPY ./bin/Release/net6.0/publish MindsphereConfigurationMover/:
------ failed to compute cache key: "/bin/Release/net6.0/publish" not found: not found
It looks like it cannot get the sdk/runtime so the following publish fails, but it makes little sense to me.
Any suggestion?
I'm guessing that you're expecting the COPY ./bin/Release/net6.0/publish app/ line to copy the published app from the project that was built earlier on in the Dockerfile. But that's not what it's actually doing. It's attempting to copy from the bin/Release/net6.0/publish of your local file system (your build context location), outside of the container. So, likely, this directory exists on your M1 Mac but not your Windows machine.
The reason it's attempting to copy from the local file system is because you've not indicated in the COPY instruction that it should copy from a Dockerfile stage. This can be done with the following syntax: COPY --from=<stage-name> <source-path> <destination-path>. In order to reference a stage name, you need to declare the stage name as well which also hasn't been done in this Dockerfile. The stage you would want to reference is that the one using the sdk image.
Here's the suggested Dockerfile to use:
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
COPY *.csproj ./
RUN dotnet restore
COPY ../*.cs ./
COPY ../Properties ./
RUN dotnet publish -c Release -o /app
FROM mcr.microsoft.com/dotnet/runtime:6.0
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["dotnet", "app.dll"]
You can see .NET Dockerfiles that demonstrate this pattern at https://github.com/dotnet/dotnet-docker/tree/main/samples.
Related
I am trying to dockerize my web API with docker and I have encountered an error MSB1001: Unkown switch. More details can be found in the cmd prompt image
Does anyone know what this means, I've tried to follow up on this in GitHub discussions and posts in StackOverflow.
My Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR C:\Users\Alexa\OneDrive\Desktop\SortIT\Api
# Copy everything
COPY . .
# Restore as distinct layers
RUN dotnet restore "./Api.csproj"
RUN dotnet publish "/Api.csproj" -c release -o ./
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
COPY --from=build /Api .
ENTRYPOINT ["dotnet", "Api.dll"]
My file directory
There are a number of issues with your Dockerfile. The one giving you the 'unknown switch' is on the publish statement, where you've given the project file name as /Api.csproj. It should be ./Api.csproj.
As others have pointed out, your WORKDIR uses Windows syntax, but you're building a Linux image and should use Linux syntax. I like to use /src as the directory in my build steps.
You publish the project to ./ which means that you'll end up with a directory that contains both your source and the published project. You want to keep them separate, so you can copy only the published project into the final image.
Which those changes, you end up with
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
# Copy everything
COPY . .
# Restore as distinct layers
RUN dotnet restore "./Api.csproj"
RUN dotnet publish "./Api.csproj" -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
COPY --from=build /src/out .
ENTRYPOINT ["dotnet", "Api.dll"]
I assume you have build context in the folder with Api.csproj file. First - WORKDIR sets the current working directory in the container. It is not a directory on the host system. You start with a directory where you copy source code from the build context to the container. Good name for it /src
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src # current directory in the container
COPY . . # Copy everything from build context to /src
RUN dotnet restore "Api.csproj"
Note that in order to optimize the build process and use caching, its better to start with copying *.csproj file only and restore dependencies. Because source code changes more often then dependencies of the application.
Next you want to build/publish your application somewhere in a container. Usually you create new directory for that and don't use the system root:
#publish app to folder /publish
RUN dotnet publish "Api.csproj" -c release -o /publish
And the last step - you should copy the published application to the runtime container. Here you set the current directory to the directory where the published application will be located:
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app #now set the current directory to /app
COPY --from=build /publish . #copy from build stage to /app
And don't forget to expose ports used by your API.
Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY "Api.csproj" .
RUN dotnet restore "Api.csproj"
COPY . .
RUN dotnet publish "Api.csproj" -c release -o /publish
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
EXPOSE 80
COPY --from=build /publish .
ENTRYPOINT ["dotnet", "Api.dll"]
Objective -> I am currently trying to integrate Dapr with a small sample project provided by the .Net project templates. At the end of my test cases, I would like to use Docker Compose to launch multiple containers for a web API and a web app to communicate with each other using the Dapr sidecars.
Problem -> Whenever I run docker compose up on the sample application, the container fails to be created and is stopped by this error:
> [build 4/7] RUN dotnet restore "MyBackEnd/MyBackEnd.csproj":
#0 0.945 Determining projects to restore...
#0 7.179 /src/MyBackEnd/MyBackEnd.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.
#0 7.202 Failed to restore /src/MyBackEnd/MyBackEnd.csproj (in 6.09 sec).
Steps to Reproduce ->
The following are the steps I took with this project:
Ran mkdir sample_project && cd sample_project
Ran dotnet new webapi -o MyBackEnd followed by cd MyBackEnd
Ran touch Dockerfile && cd .. && touch docker-compose.yml
I then put this in my Dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:6.0-focal AS base
WORKDIR /app
RUN apt-get update && apt-get install -y libcurl4
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0-focal AS build
WORKDIR /src
COPY ["MyBackEnd/MyBackEnd.csproj", "MyBackEnd/"]
RUN dotnet restore "MyBackEnd/MyBackEnd.csproj"
COPY . .
WORKDIR "/src/MyBackEnd"
RUN dotnet build "MyBackEnd.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MyBackEnd.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyBackEnd.dll"]
And this was what I did with my Docker Compose YAML file:
version: '3.4'
services:
mybackend:
image: ${DOCKER_REGISTRY-}mybackend
build:
context: .
dockerfile: MyBackEnd/Dockerfile
ports:
- "3000:80"
Finally, I ran docker compose up to arrive at the issue
Additional Information -> I am not running this on a Windows system. I am using Ubuntu 20, and thus, I do not have access to Visual Studio to handle the launching and configuration for me. I am aware that this is a heavily replicated question, but I have yet to see anything that specifically applies to users that do not have access to Visual Studio or on Ubuntu. Thanks!
I am hosting my own build-agent on my on-premises windows server.
However, when I either try to build my docker image using the default agent or my on-premisses agent, it cannot copy the .cproj files.
What I want, is to be able to build this image without the errors.
What I have tried so far is:
Changes work directory to: ../ , ../../ and ~/
Google for solutions, but this does not result in anything, because it is too specific or something.
Please note that it also does not work on an agent from DevOps itself (windows-2022)
Does anyone know what I could have done wrong or overlooked?
Directories:
src/Server/DockerFile
src/Server/Server.csproj
And so on for the other .csproj files
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
ENV ASPNETCORE_URLS=https://+:5005;http://+:5006
WORKDIR /app
EXPOSE 5005
EXPOSE 5006
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /
COPY ["src/Server/Server.csproj", "src/Server/"]
COPY ["src/Application/Application.csproj", "src/Application/"]
COPY ["src/Domain/Domain.csproj", "src/Domain/"]
COPY ["src/Shared/Shared.csproj", "src/Shared/"]
COPY ["src/Infrastructure.Shared/Infrastructure.Shared.csproj", "src/Infrastructure.Shared/"]
COPY ["src/Infrastructure/Infrastructure.csproj", "src/Infrastructure/"]
COPY ["src/Client/Client.csproj", "src/Client/"]
COPY ["src/Client.Infrastructure/Client.Infrastructure.csproj", "src/Client.Infrastructure/"]
RUN dotnet restore "src/Server/Server.csproj" --disable-parallel
COPY . .
WORKDIR "src/Server"
RUN dotnet build "Server.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Server.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
WORKDIR /app/Files
WORKDIR /app
ENTRYPOINT ["dotnet", "DeDenDannenburcht.Server.dll"]
My Pipeline
Pipeline Output
"C:\Program Files\Docker\Docker\resources\bin\docker.exe" build -f F:\agents\_work\1\s\src\Server\Dockerfile -t dedendannenburcht:166 --label com.azure.dev.image.system.teamfoundationcollectionuri=https://dev.azure.com/JeremiedevosBusiness/ --label com.azure.dev.image.build.sourceversion=ab657210c8696881754f36393adee9da7394ea19 --label image.base.ref.name=mcr.microsoft.com/dotnet/aspnet:6.0 --label image.base.digest=sha256:545da8027d0de13ac88716fc380201f05ad9b4834b5b2fd95eadf277e51318a7 F:\agents\_work\1\s\src\Server
#1 [internal] load build definition from Dockerfile
#1 sha256:5cec5c1a6e883854d5ef516a04f7fbc4f77cc63f74549820c4d061dbb560e514
#1 transferring dockerfile: 1.31kB done
#1 DONE 0.0s
#2 [internal] load .dockerignore
#2 sha256:8f7ecf610ac80d8ac3c3e64e4de2e264ecf11892bf7afc5ff6debe41dd69161b
#2 transferring context: 2B done
#2 DONE 0.0s
#4 [internal] load metadata for mcr.microsoft.com/dotnet/aspnet:6.0
#4 sha256:ac4494cbca04ddb415c76edcbcc7688784c2a6ea65dd656286c013738aa3b75f
#4 DONE 0.0s
#3 [internal] load metadata for mcr.microsoft.com/dotnet/sdk:6.0
#3 sha256:9eb4f6c3944cfcbfe18b9f1a753c769fc35341309a8d4a21f8937f47e94c712b
#3 DONE 0.1s
#5 [base 1/2] FROM mcr.microsoft.com/dotnet/aspnet:6.0
#5 sha256:50f1ddc10932c4a74c7af5704e931a9489c710faea4f2381fe2380827a900e00
#5 DONE 0.0s
#6 [base 2/2] WORKDIR /app
#6 sha256:bc3cf6c390e5fe0e66017b4845c8fcf3e56c7adac9f514a00c2c986024f377a4
#6 CACHED
#7 [final 1/4] WORKDIR /app
#7 sha256:3baba3edbb555769ad9a49e827de88d7dcc4f72ad6e2b42e576964e4a30eac96
#7 CACHED
#8 [build 1/14] FROM mcr.microsoft.com/dotnet/sdk:6.0#sha256:a3dd4dee05cd1369014244d03b28b602e6a2e1650210dd8633322e00379471ec
#8 sha256:ff704f84298cdcbd6cd764720a2e1a4dcd4b44ff415133896e77ad0c5d908001
#8 resolve mcr.microsoft.com/dotnet/sdk:6.0#sha256:a3dd4dee05cd1369014244d03b28b602e6a2e1650210dd8633322e00379471ec done
#8 sha256:0af6b8199917326984baa1452533da610b46f65bfbc5296c7f81cb72d3beec84 2.01kB / 2.01kB done
#8 sha256:dc243ad423c72b21b838c1362ca152823b0b379a546887d8c47c437357576fb2 7.31kB / 7.31kB done
#8 sha256:664e00cfda3df2ac7370c116f04a17d636fc041b62bdd9a0b88a60b987344269 0B / 136.50MB 0.1s
#8 sha256:a3dd4dee05cd1369014244d03b28b602e6a2e1650210dd8633322e00379471ec 2.17kB / 2.17kB done
#8 sha256:4253139ebd4dcee5f7878254306eb794d0f2a80ee4ca8d085d0b9e507412fb1e 0B / 25.36MB 0.1s
#10 sha256:aa96c6c99b71465c230e63fb1edea0588e2b25c39d6b44fc1381e7cbe48c15d9
#10 ERROR: "/src/Server/Server.csproj" not found: not found
#13 [build 5/14] COPY [src/Shared/Shared.csproj, src/Shared/]
#13 sha256:8fd70ae770f73428f5ff667da9b5080dff2b8035dbeb1247fe9e76d5890ad27d
#13 ERROR: "/src/Shared/Shared.csproj" not found: not found
#16 [build 8/14] COPY [src/Client/Client.csproj, src/Client/]
#16 sha256:33c15418c5097a788d8ef568338206ce45e5fea62b707a2be13c136b28ca43e9
#16 ERROR: "/src/Client/Client.csproj" not found: not found
#15 [build 7/14] COPY [src/Infrastructure/Infrastructure.csproj, src/Infrastructure/]
#15 sha256:4f643811b59a89db4a864a2a40a7ff2cc05709c3b123027874b72ff436af0d56
#15 ERROR: "/src/Infrastructure/Infrastructure.csproj" not found: not found
#17 [build 9/14] COPY [src/Client.Infrastructure/Client.Infrastructure.csproj, src/Client.Infrastructure/]
#17 sha256:b7385969b745977db24f702bc1c8f0b931cd675b9f44e70870ae2d918632e9b3
#17 ERROR: "/src/Client.Infrastructure/Client.Infrastructure.csproj" not found: not found
#14 [build 6/14] COPY [src/Infrastructure.Shared/Infrastructure.Shared.csproj, src/Infrastructure.Shared/]
#14 sha256:f101a94226cbf6f38fe9d908da512ded2bd68070207a6dd5c003d8967252c970
#14 ERROR: "/src/Infrastructure.Shared/Infrastructure.Shared.csproj" not found: not found
#12 [build 4/14] COPY [src/Domain/Domain.csproj, src/Domain/]
#12 sha256:152a7025db6bab6e2e456a9ab7ef8436cc9689411341ea38c362df78a0d058c1
#12 ERROR: "/src/Domain/Domain.csproj" not found: not found
#11 [build 3/14] COPY [src/Application/Application.csproj, src/Application/]
#11 sha256:1760818b73b46bb8ebf75492933a413de08fd2ab7a26cae37de4ae4a5f60b83e
#11 ERROR: "/src/Application/Application.csproj" not found: not found
------
> [build 2/14] COPY [src/Server/Server.csproj, src/Server/]:
------
------
> [build 3/14] COPY [src/Application/Application.csproj, src/Application/]:
------
------
> [build 4/14] COPY [src/Domain/Domain.csproj, src/Domain/]:
------
------
> [build 5/14] COPY [src/Shared/Shared.csproj, src/Shared/]:
------
------
> [build 6/14] COPY [src/Infrastructure.Shared/Infrastructure.Shared.csproj, src/Infrastructure.Shared/]:
------
------
> [build 7/14] COPY [src/Infrastructure/Infrastructure.csproj, src/Infrastructure/]:
------
------
> [build 8/14] COPY [src/Client/Client.csproj, src/Client/]:
------
------
> [build 9/14] COPY [src/Client.Infrastructure/Client.Infrastructure.csproj, src/Client.Infrastructure/]:
------
failed to compute cache key: "/src/Client.Infrastructure/Client.Infrastructure.csproj" not found: not found
##[error]The process 'C:\Program Files\Docker\Docker\resources\bin\docker.exe' failed with exit code 1
Finishing: Build an image
The Dockerfile is located under src\Server. The Build an image step calls docker build -f .\src\Server\Dockerfile .\src\Server which will not work because that is already one level too deep in the directory tree.
So there are several options:
Call docker build -f .\src\Server\Dockerfile . from the root directory, but use a custom shell script rather than the official Build an image step - it seems to have that kind of limitation.
Use relative paths in the Dockerfile like this:
COPY ["../src/Server/Server.csproj", "src/Server/"]
Move the Dockerfile to the root directory.
I've generated a basic Kubernetes Web Application in Visual Studio 2019, v16.11.1, which allowed me to automatically generate a Dockerfile and start debugging. However, upon switching to a Release configuration, the build fails when the internal dotnet restore command executes. Apparently upon trying to pull Nuget packages from a feed, the dotnet restore rejects the SSL certificate provided by the Nuget feed server.
My question is, what am I doing wrong? I started with literally the default web application program generated by Visual Studio, and it automatically fails when I try to build a Release config. See here for more detail:
The Issue
The following Dockerfile can be built in a debug configuration, but not in a Release configuration.
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY ["KubernetesWebApp/KubernetesWebApp.csproj", "KubernetesWebApp/"]
RUN dotnet restore "KubernetesWebApp/KubernetesWebApp.csproj"
COPY . .
WORKDIR "/src/KubernetesWebApp"
RUN dotnet build "KubernetesWebApp.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "KubernetesWebApp.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "KubernetesWebApp.dll"]
Clicking "Debug" to start a debug session executes the following build, and I can debug the application:
docker build -f ".\KubernetesWebApp\Dockerfile" --force-rm -t kuberneteswebapp:dev --target base --label "com.microsoft.created-by=visual-studio" --label "com.microsoft.visual-studio.project-name=KubernetesWebApp" .
However, upon attempting the following build command, the dotnet restore command fails due to a remote SSL certificate check failure:
docker build -t kuberneteswebapp:latest -f KubernetesWebApp/Dockerfile .
This elicits the following error:
[+] Building 7.7s (12/17)
=> [internal] load build definition from Dockerfile 0.4s
=> => transferring dockerfile: 32B 0.2s
=> [internal] load .dockerignore 0.3s
=> => transferring context: 35B 0.0s
=> [internal] load metadata for mcr.microsoft.com/dotnet/core/aspnet:3.1 0.8s
=> [internal] load metadata for mcr.microsoft.com/dotnet/core/sdk:3.1 0.8s
=> [internal] load build context 0.3s
=> => transferring context: 644B 0.1s
=> [build 1/7] FROM mcr.microsoft.com/dotnet/core/sdk:3.1#sha256:aa984bf37de864afe9f34bc80e42412dd95702b94731a481821eeae364df77ae 0.2s
=> => resolve mcr.microsoft.com/dotnet/core/sdk:3.1#sha256:aa984bf37de864afe9f34bc80e42412dd95702b94731a481821eeae364df77ae 0.2s
=> [base 1/2] FROM mcr.microsoft.com/dotnet/core/aspnet:3.1#sha256:9280563285e34929fdae56b8759d8050169b3ce125a5dced64945b3b51e79918 0.3s
=> => resolve mcr.microsoft.com/dotnet/core/aspnet:3.1#sha256:9280563285e34929fdae56b8759d8050169b3ce125a5dced64945b3b51e79918 0.3s
=> CACHED [base 2/2] WORKDIR /app 0.0s
=> CACHED [final 1/2] WORKDIR /app 0.0s
=> CACHED [build 2/7] WORKDIR /src 0.0s
=> CACHED [build 3/7] COPY [KubernetesWebApp/KubernetesWebApp.csproj, KubernetesWebApp/] 0.0s
=> ERROR [build 4/7] RUN dotnet restore "KubernetesWebApp/KubernetesWebApp.csproj" 5.5s
------
> [build 4/7] RUN dotnet restore "KubernetesWebApp/KubernetesWebApp.csproj":
#12 3.363 Determining projects to restore...
#12 5.397 /usr/share/dotnet/sdk/3.1.412/NuGet.targets(128,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/src/KubernetesWebApp/KubernetesWebApp.csproj]
#12 5.397 /usr/share/dotnet/sdk/3.1.412/NuGet.targets(128,5): error : The SSL connection could not be established, see inner exception. [/src/KubernetesWebApp/KubernetesWebApp.csproj]
#12 5.397 /usr/share/dotnet/sdk/3.1.412/NuGet.targets(128,5): error : The remote certificate is invalid according to the validation procedure. [/src/KubernetesWebApp/KubernetesWebApp.csproj]
------
executor failed running [/bin/sh -c dotnet restore "KubernetesWebApp/KubernetesWebApp.csproj"]: exit code: 1
What I Think the Problem Is
I think the issue arises when :
The docker container attempts to pull Nuget packages from a nuget feed,
During identity verification it checks the provided server certificate
Due to some specified validation procedure, the server certificate fails verification.
What I've Tried to Fix It
I've tried the following commands to force the application to download new base container images, but to no avail:
Attempt 1:
docker build --no-cache --pull -t kuberneteswebapp:latest -f KubernetesWebApp/Dockerfile .
Result: Same error as before
Attempt 2:
docker system prune
docker image prune -a
docker build --no-cache --pull -t kuberneteswebapp:latest -f KubernetesWebApp/Dockerfile .
result: Same error as before
Neither of these efforts have succeeded. Can anyone help me? I'm at a loss here.
The issue fixed itself. I just reattempted both my test and actual projects and it works now. This could have been a software update or a computer restart. But everything works now.
If you are using Windows containers, I recommend switching to a Linux container and trying it out again. (You can do so by right clicking the Docker desktop icon in the system tray bar).
I came across the following issue on GitHub: https://github.com/docker/for-win/issues/2760#issuecomment-430889666 I was unable to reproduce your issue with a fresh ASP .NET Web API
I have followed all the steps in the tutorial Tutorial: Develop IoT Edge modules for Windows devices
I have signed into docker desktop.
However when I try and build and publish I get the following error in the output window
> DOCKER_HOST:
DOCKER_TLS_VERIFY:
DOCKER_CERT_PATH:
Additional Env Variables:
------ Build and Push IoT Edge Modules started: Platform: Windows Amd64, Configuration: Release ------
The deployment manifest is generated at C:\Users\bar\source\repos\AzureIotEdgeApp3\config\deployment.windows-amd64.json
docker build --rm -f "C:\Users\bar\source\repos\IotEdgeModule3\Dockerfile.windows-amd64" -t FOO.azurecr.io/iotedgemodule3:0.0.1-windows-amd64 "C:\Users\bar\source\repos\IotEdgeModule3"
#2 (internal) load .dockerignore
#2 transferring context: 2B done
#2 DONE 0.1s
#1 (internal) load build definition from Dockerfile.windows-amd64
#1 transferring dockerfile: 46B 0.0s done
#1 DONE 0.1s
#3 (internal) load metadata for mcr.microsoft.com/dotnet/core/runtime:3.1-n...
#3 DONE 0.0s
#4 (internal) load metadata for mcr.microsoft.com/dotnet/core/sdk:3.1-nanos...
#4 DONE 0.0s
#5 (stage-1 1/3) FROM mcr.microsoft.com/dotnet/core/runtime:3.1-nanoserver-...
#5 CACHED
#9 (internal) load build context
#9 transferring context: 1.20kB 0.0s done
#9 DONE 0.2s
#6 (stage-1 2/3) WORKDIR /app
#6 ERROR: open /var/lib/docker/overlay2/78d2cb8633edf0eef3af53faff16f4b1570ca332555085bcadcb185c037611dd/merged/etc/passwd: no such file or directory
#7 (build-env 1/6) FROM mcr.microsoft.com/dotnet/core/sdk:3.1-nanoserver-18...
#7 resolve mcr.microsoft.com/dotnet/core/sdk:3.1-nanoserver-1809#sha256:aeab6d06ece872b88e59c4da0a98aa64e637aa979a161923658c5f7ef74b9699 done
#7 sha256:918abb37d3f2ac5ee5f9ad3d2017bebcdc353838e7097f5be7fda8c7df590489 4.36kB / 4.36kB done
#7 sha256:aeab6d06ece872b88e59c4da0a98aa64e637aa979a161923658c5f7ef74b9699 3.43kB / 3.43kB done
#7 CANCELED
> (stage-1 2/3) WORKDIR /app:
failed to solve with frontend dockerfile.v0: failed to build LLB: open /var/lib/docker/overlay2/78d2cb8633edf0eef3af53faff16f4b1570ca332555085bcadcb185c037611dd/merged/etc/passwd: no such file or directory
(ERROR): Build docker image failed: #2 (internal) load .dockerignore
#2 transferring context: 2B done
#2 DONE 0.1s
#1 (internal) load build definition from Dockerfile.windows-amd64
#1 transferring dockerfile: 46B 0.0s done
#1 DONE 0.1s
#3 (internal) load metadata for mcr.microsoft.com/dotnet/core/runtime:3.1-n...
#3 DONE 0.0s
#4 (internal) load metadata for mcr.microsoft.com/dotnet/core/sdk:3.1-nanos...
#4 DONE 0.0s
#5 (stage-1 1/3) FROM mcr.microsoft.com/dotnet/core/runtime:3.1-nanoserver-...
#5 CACHED
#9 (internal) load build context
#9 transferring context: 1.20kB 0.0s done
#9 DONE 0.2s
#6 (stage-1 2/3) WORKDIR /app
#6 ERROR: open /var/lib/docker/overlay2/78d2cb8633edf0eef3af53faff16f4b1570ca332555085bcadcb185c037611dd/merged/etc/passwd: no such file or directory
#7 (build-env 1/6) FROM mcr.microsoft.com/dotnet/core/sdk:3.1-nanoserver-18...
#7 resolve mcr.microsoft.com/dotnet/core/sdk:3.1-nanoserver-1809#sha256:aeab6d06ece872b88e59c4da0a98aa64e637aa979a161923658c5f7ef74b9699 done
#7 sha256:918abb37d3f2ac5ee5f9ad3d2017bebcdc353838e7097f5be7fda8c7df590489 4.36kB / 4.36kB done
#7 sha256:aeab6d06ece872b88e59c4da0a98aa64e637aa979a161923658c5f7ef74b9699 3.43kB / 3.43kB done
#7 CANCELED
> (stage-1 2/3) WORKDIR /app:
failed to solve with frontend dockerfile.v0: failed to build LLB: open /var/lib/docker/overlay2/78d2cb8633edf0eef3af53faff16f4b1570ca332555085bcadcb185c037611dd/merged/etc/passwd: no such file or directory
I am trying this on a Windows 10 Pro, x64 computer with latest version of Visual studio Version 16.8.0 and Docker Windows Desktop (stable) installed yesterday.
I have tried reinstalling docker and creating the visual studio projects, however I still get the same error.
this is docker file Dockerfile.windows-amd64:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-nanoserver-1809 AS build-env
WORKDIR /app
COPY *.csproj ./
RUN dotnet restore
COPY . ./
RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/core/runtime:3.1-nanoserver-1809
WORKDIR /app
COPY --from=build-env /app/out ./
ENTRYPOINT ["dotnet", "IotEdgeModule3.dll"]
Kgalic is correct, I Docker was running using Linux by Default. I switched to Windows by using the context menu on the docker icon in the system try.