I created a Container Application for Kubernetes in Visual Studio as follows:
Docker file looks like this:
Result from running in Powershell with success:
I tried using the pipeline template - Deploy to Azure Kubernetes Service:
I used the YAML "as-is":
When I save and run, I get the following:
Please advise
[error]COPY failed: stat /var/lib/docker/tmp/docker-builder947419078/KubeApp/KubeApp.csproj: no such file or directory
The cause of this error is actually due to the different execution mechanisms between pipeline and local when running the dockerfile.
For pipeline
, it is by default running the docker in the directory where the dockerfile lives which is at the project level, but VS/local
runs it at the Repos/Solution level.
So, to solve this issue, you can try with below method
Change the COPY
definition as:
COPY ["KubeApp.csproj", "KubeApp/"]
This method can let you succeed to COPY
, but failed with Program does not contain a static 'Main' method
.
At this time:
COPY . .
(L10) to COPY . KubeApp/
. This will add folder to dest path.COPY
(L10) and WORKDIR
(L11) without change the COPY . .
.See my previous answer that others solved the same issue by applying my suggestion.