<p>I'm trying to deploy a simple .NET App in local kubernetes cluster (Kind) for testing purposes. When a deployment is applied, a pod doesn't start with an error. But the image is built well as a container works well if started locally in Docker.</p>
<pre><code>NAME                             READY   STATUS    RESTARTS   AGE
orderproducer-68d5ff7944-d2d89   0/1     Error     4          103s
</code></pre>
<pre><code>kubectl logs -l app=orderproducer

Could not execute because the application was not found or a compatible .NET SDK is not installed.
Possible reasons for this include:
  * You intended to execute a .NET program:
      The application 'OrderProducer.dll' does not exist.
  * You intended to execute a .NET SDK command:
      It was not possible to find any installed .NET SDKs.
      Install a .NET SDK from:
        https://aka.ms/dotnet-download
</code></pre>
<p>It's weird, because if I start a docker container from the same image locally (not in a cluster) it works well. Besides, I had run bash on that container and ensured that <code>OrderProducer.dll</code> was really presented in the <code>/app</code> folder (which is a workdir).</p>
<pre><code>xxx@xxx:/mnt/c/Users/xxx$ docker run --name test6 orderproducer:latest
Order Producer has started!
Kafka broker: 127.0.0.1:9092
</code></pre>
<p>Do you have any ideas what's my mistake? Why it run in Docker, but not in a K8s's pod? I've already spent about 3 hours trying to figure out, but still not. Many thanks in advance.</p>
<p>Here are some artifacts I used.</p>
<p>Dockerfile:</p>
<pre><code>FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY [&quot;OrderProducer/OrderProducer.csproj&quot;, &quot;OrderProducer/&quot;]
COPY [&quot;Common/Common.csproj&quot;, &quot;Common/&quot;]
RUN dotnet restore &quot;OrderProducer/OrderProducer.csproj&quot;
COPY . .
WORKDIR &quot;/src/OrderProducer&quot;
RUN dotnet build &quot;OrderProducer.csproj&quot; -c Release -o /app/build

FROM build AS publish
RUN dotnet publish &quot;OrderProducer.csproj&quot; -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT [&quot;dotnet&quot;, &quot;OrderProducer.dll&quot;]
</code></pre>
<p>Then I build an image and make it accessible for kind:</p>
<pre><code>docker build -f OrderProducer/Dockerfile -t orderproducer:latest .
kind load docker-image orderproducer:latest
</code></pre>
<p>Then I apply a deployment:</p>
<pre><code>kubectl apply -f orderproducer-deployment.yml
</code></pre>
<p>orderproducer-deployment.yml</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: orderproducer
spec:
  replicas: 1
  selector:
    matchLabels:
      app: orderproducer
  template:
    metadata:
      labels:
        app: orderproducer
    spec:
      containers:
      - name: orderproducer
        image: orderproducer:latest
        imagePullPolicy: Never
        resources:
          limits:
            memory: &quot;128Mi&quot;
            cpu: &quot;500m&quot;
</code></pre>

<p>The reason was when a volume was mounted to <code>/app</code> it wiped out all the container's <code>/app</code> content.</p>
<p>I fixed the issue by editing the following deployment's part:</p>
<pre><code>volumeMounts:
        - name: appsettings-volume
          mountPath: /app/appSettings.json
          subPath: appSettings.json
</code></pre>
