<p>I have an ASP.Net Core Web API 2.2 project that runs normally on my local Docker Desktop. I'm trying to run it on Azure's AKS, but it won't run there, and I can't understand why.<br>
Below is my PowerShell script that I use to publish my project into a <code>app</code> directory that will be later inserted into the container:</p>

<pre><code>Remove-Item ..\..\..\..\projects\MyProject.Selenium.Commom\src\Selenium.API\bin\Release\* -Force -Recurse
dotnet publish ..\..\..\..\projects\MyProject.Selenium.Commom\src\Selenium.Comum.sln -c Release -r linux-musl-x64
$path = (Get-Location).ToString() + "\app"
if (Test-Path($path))
{
    Remove-Item -Path $path -Force -Recurse
}
New-Item -ItemType Directory -Force app
Get-ChildItem ..\..\..\..\projects\MyProject.Selenium.Commom\src\Selenium.API\bin\Release\netcoreapp2.2\linux-musl-x64\publish\* | Copy-Item -Destination .\app -Recurse
</code></pre>

<p>Here is my <code>Dockerfile</code></p>

<pre><code># Build runtime image
FROM mcr.microsoft.com/dotnet/core/runtime:2.2-alpine3.9
WORKDIR /app /app
WORKDIR /app
ENTRYPOINT ["dotnet", "Selenium.API.dll"]
</code></pre>

<p>Below is my Docker build command:</p>

<pre><code>docker build -t mylocaldocker/selenium-web-app:latest -t mylocaldocker/selenium-web-app:v0.0.2 .
</code></pre>

<p>And my Docker run command</p>

<pre><code>docker run --name selweb --detach --rm -p 85:80 mylocaldocker/selenium-web-app:latest
</code></pre>

<p>Everything spins up nice and smooth, and I'm able to send requests locally on port 85 without an issue (port 80 is being used by IIS)<br>
However, doing similar procedures on Azure's AKS, the container won't start. I use the identical PowerShell script to publish my application, and the dockerfile is identical as well. My build command changes so that I can push to Azure's Docker Registry:</p>

<pre><code>docker build -t myproject.azurecr.io/selenium-web-app:latest -t myproject.azurecr.io/selenium-web-app:v0.0.1 .
</code></pre>

<p>I login to the Azure Docker Registry, and push the image to it:</p>

<pre><code>docker push myproject.azurecr.io/selenium-web-app:latest
</code></pre>

<p>I've already created my AKS cluster and gave permission to pull images from my registry. I try to run the image on AKS using the command:</p>

<pre><code>kubectl run seleniumweb --image myproject.azurecr.io/selenium-web-app:latest --port 80
</code></pre>

<p>And I get the response </p>

<pre><code>deployment.apps "seleniumweb" created
</code></pre>

<p>However, when I get the running pods:</p>

<pre><code>kubectl get pods
</code></pre>

<p>I get an error Status on my pod</p>

<pre><code>NAME                           READY     STATUS    RESTARTS   AGE
seleniumweb-7b5f645698-9g7f6   0/1       Error     4          1m
</code></pre>

<p>When I get the logs from the pod:</p>

<pre><code>kubectl logs seleniumweb-7b5f645698-9g7f6
</code></pre>

<p>I get this back:</p>

<pre><code>Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
  https://go.microsoft.com/fwlink/?LinkID=798306&amp;clcid=0x409
</code></pre>

<p>Below is the result of kubectl describe for the pod:</p>

<pre><code>kubectl describe pods
Name:               seleniumweb-7b5f645698-9g7f6
Namespace:          default
Priority:           0
PriorityClassName:  &lt;none&gt;
Node:               aks-agentpool-41564776-0/10.240.0.4
Start Time:         Sun, 02 Jun 2019 11:40:47 -0300
Labels:             pod-template-hash=7b5f645698
                    run=seleniumweb
Annotations:        &lt;none&gt;
Status:             Running
IP:                 10.240.0.25
Controlled By:      ReplicaSet/seleniumweb-7b5f645698
Containers:
  seleniumweb:
    Container ID:   docker://1d548f4934632efb0b7c5a59dd0ac2bd173f2ee8fa5196b45d480fb10e88a536
    Image:          myproject.azurecr.io/selenium-web-app:latest
    Image ID:       docker-pullable://myproject.azurecr.io/selenium-web-app@sha256:97e2915a8b43aa8e726799b76274bb9b5b852cb6c78a8630005997e310cfd41a
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:    145
      Started:      Sun, 02 Jun 2019 11:43:39 -0300
      Finished:     Sun, 02 Jun 2019 11:43:39 -0300
    Ready:          False
    Restart Count:  5
    Environment:
      KUBERNETES_PORT_443_TCP_ADDR:  myprojectus-dns-54302b78.hcp.eastus2.azmk8s.io
      KUBERNETES_PORT:               tcp://myprojectus-dns-54302b78.hcp.eastus2.azmk8s.io:443
      KUBERNETES_PORT_443_TCP:       tcp://myprojectus-dns-54302b78.hcp.eastus2.azmk8s.io:443
      KUBERNETES_SERVICE_HOST:       myprojectus-dns-54302b78.hcp.eastus2.azmk8s.io
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-mhvfv (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  default-token-mhvfv:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-mhvfv
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  &lt;none&gt;
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason     Age                From                               Message
  ----     ------     ----               ----                               -------
  Normal   Scheduled  5m                 default-scheduler                  Successfully assigned default/seleniumweb-7b5f645698-9g7f6 to aks-agentpool-41564776-0
  Normal   Created    4m (x4 over 5m)    kubelet, aks-agentpool-41564776-0  Created container
  Normal   Started    4m (x4 over 5m)    kubelet, aks-agentpool-41564776-0  Started container
  Normal   Pulling    3m (x5 over 5m)    kubelet, aks-agentpool-41564776-0  pulling image "myproject.azurecr.io/selenium-web-app:latest"
  Normal   Pulled     3m (x5 over 5m)    kubelet, aks-agentpool-41564776-0  Successfully pulled image "myproject.azurecr.io/selenium-web-app:latest"
  Warning  BackOff    20s (x24 over 5m)  kubelet, aks-agentpool-41564776-0  Back-off restarting failed container
</code></pre>

<p>And I don't understand why, since everything runs fine on my local Docker. Any help would be greatly appreciated. Thanks</p>

Pascal
<p>That Dockerfile looks funny.  It doesn't do anything.  WORKDIR just "sets the working directory for any RUN, CMD, ENTRYPOINT, COPY and ADD instructions that follow it in the Dockerfile" (from <a href="https://docs.docker.com/engine/reference/builder/#workdir" rel="nofollow noreferrer">docs.docker.com</a>).  So you're setting the working directory twice, then nothing else.  And the entrypoint would then point to a nonexistent .dll since you never copied it over.  I think you want to delete the first WORKDIR command and add this after the remaining WORKDIR command:</p>

<pre><code>COPY . ./
</code></pre>

<p>Even better, use a <a href="https://docs.docker.com/engine/examples/dotnetcore/" rel="nofollow noreferrer">two stage build</a> so it builds on docker, then copies the build to a runtime image that is published.</p>

<p>I don't know why docker run is working locally for you.  Is it picking up an old image somehow?  Based on your Dockerfile, it shouldn't run.</p>
