after i added a docker-compose project the asp.net solution, then i try to build the docker-compose file to generate all the images.
however i always encounter error without specific message. the root of cause this issue is that
YAML follows indentation structure very strictly. one extra space or tab will cause this issue.
this online tool will be a great help on validation your content in YAML.
https://onlineyamltools.com/validate-yaml
here is my sample docker-compose file, after i pasted it in the yaml box, the line causes the issue highlights immediately in the errors box
version: '3.7'
services:
webapi_dotnetcore:
image: ${DOCKER_REGISTRY-}webapidotnetcore
build:
context: .
dockerfile: WebAPI_DotNetCore/Dockerfile
db:
image: mcr.microsoft.com/mssql/server
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=Password_01
ports:
- '1433:1433'
a blog to share Microsoft technologies Azure, DotNet, SharePoint, SQL Server,JavaScript Framework: Node.JS, Angular, React
Showing posts with label Microservices. Show all posts
Showing posts with label Microservices. Show all posts
Monday, February 24, 2020
Sunday, February 23, 2020
How to fix COPY failed COPY failed: stat /var/lib/docker/tmp/docker-builder/appFolder/App.csproj: no such file or directory issue in Docker Build command to create a docker image in Microservice project?
I am playing with the Microservices application with docker enable in my local development.
after i completely setup my project. i try to manipulate the project with docker building command.
since the dockerfile had been automatically generated by visual studio, when i create a dotnet core web api project with docker support.
how ever when i run this command to create a docker image
docker build . -t myimage -f dockerfile
it encountered an error on the copy step. i put the step with error in bold.
FROM mcr.microsoft.com/dotnet/core/aspnet:2.1-stretch-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:2.1-stretch AS build
WORKDIR /src
COPY ["simplemicroservicesApp/simplemicroservicesApp.csproj", "simplemicroservicesApp/"]
RUN dotnet restore "simplemicroservicesApp/simplemicroservicesApp.csproj"
COPY . .
WORKDIR "/src/simplemicroservicesApp"
RUN dotnet build "simplemicroservicesApp.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "simplemicroservicesApp.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "simplemicroservicesApp.dll"]
here is the error message
Step 7/17 : COPY ["simplemicroservicesApp/simplemicroservicesApp.csproj", "simplemicroservicesApp/"]
COPY failed: stat /var/lib/docker/tmp/docker-builder663072116/simplemicroservicesApp/simplemicroservicesApp.csproj: no such file or directory
the root of cause of this issue is that Visual Studio generated the dockerfile inside the project folder. actually it should be in the solution folder.
by default the dockerfile was generated inside the project folder

actually it should be in the solution level in order to build a docker image properly.
after i cut and paste the file into the solution folder, then navigate to the solution folder in window CMD, and execute the following line to create a docker image.
docker build . -t myimage -f dockerfile
after i completely setup my project. i try to manipulate the project with docker building command.
since the dockerfile had been automatically generated by visual studio, when i create a dotnet core web api project with docker support.
how ever when i run this command to create a docker image
docker build . -t myimage -f dockerfile
it encountered an error on the copy step. i put the step with error in bold.
FROM mcr.microsoft.com/dotnet/core/aspnet:2.1-stretch-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:2.1-stretch AS build
WORKDIR /src
COPY ["simplemicroservicesApp/simplemicroservicesApp.csproj", "simplemicroservicesApp/"]
RUN dotnet restore "simplemicroservicesApp/simplemicroservicesApp.csproj"
COPY . .
WORKDIR "/src/simplemicroservicesApp"
RUN dotnet build "simplemicroservicesApp.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "simplemicroservicesApp.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "simplemicroservicesApp.dll"]
here is the error message
Step 7/17 : COPY ["simplemicroservicesApp/simplemicroservicesApp.csproj", "simplemicroservicesApp/"]
COPY failed: stat /var/lib/docker/tmp/docker-builder663072116/simplemicroservicesApp/simplemicroservicesApp.csproj: no such file or directory
the root of cause of this issue is that Visual Studio generated the dockerfile inside the project folder. actually it should be in the solution folder.
by default the dockerfile was generated inside the project folder
actually it should be in the solution level in order to build a docker image properly.
after i cut and paste the file into the solution folder, then navigate to the solution folder in window CMD, and execute the following line to create a docker image.
docker build . -t myimage -f dockerfile
Subscribe to:
Posts (Atom)

