<p>I have a Docker image that I can run with no problems on my local machine but when I try to run it in a Kubernetes cluster the container fails to start because it can't execute the start up command for the app.</p>

<p>I'm copying the <code>dist</code> directory over because that is where I packaged my app. If I wanted to run it locally all I need to do is run <code>./dist/bin/start</code> and then the app would start. This is the structure of the directory.</p>

<pre><code>dist/
├── bin
│   └── start
├── conf
│   ├── application.conf
│   ├── routes
│   └── secure.conf
├── my-play-framework-api-0.1.0-SNAPSHOT
└── lib
</code></pre>

<p>This is the <code>Dockerfile</code> that I am using.</p>

<pre><code>FROM openjdk:11-jre-slim
COPY dist /dist
EXPOSE 9000 9443
WORKDIR /dist
CMD ["/dist/bin/start","-Dhttps.port=9443"]
</code></pre>

<p>I can build and run this image using the <code>docker run</code> command.</p>

<p>The problems start appearing when I pull this image from the Gitlab registry from my Kubernetes cluster. The image pulls successfully according the output when I <code>describe</code> the Pod that the container is running in. It seems like that container is not starting because it can't locate the <code>/dist</code> directory even after I copied it in the Dockerfile.</p>

<pre><code>Events:
  Type     Reason     Age                  From                                                    Message
  ----     ------     ----                 ----                                                    -------
  Normal   Scheduled  12m                  default-scheduler                                       Successfully assigned &lt;REDACTED&gt;/&lt;REDACTED&gt;-&lt;REDACTED&gt; to &lt;REDACTED&gt;.eu-central-1.compute.internal
  Normal   Pulled     11m (x5 over 12m)    kubelet, &lt;REDACTED&gt;.eu-central-1.compute.internal  Successfully pulled image "&lt;REDACTED&gt;/&lt;REDACTED&gt;/&lt;REDACTED&gt;/&lt;REDACTED&gt;"
  Normal   Created    11m (x5 over 12m)    kubelet, &lt;REDACTED&gt;.eu-central-1.compute.internal  Created container
  Warning  Failed     11m (x5 over 12m)    kubelet, &lt;REDACTED&gt;.eu-central-1.compute.internal  Error: failed to start container "&lt;REDACTED&gt;": Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"/dist/bin/start\": stat /dist/bin/start: no such file or directory": unknown
  Normal   Pulling    10m (x6 over 12m)    kubelet, &lt;REDACTED&gt;.eu-central-1.compute.internal  pulling image "registry.gitlab.com/&lt;REDACTED&gt;/&lt;REDACTED&gt;/&lt;REDACTED&gt;"
  Warning  BackOff    119s (x44 over 11m)  kubelet, &lt;REDACTED&gt;.eu-central-1.compute.internal  Back-off restarting failed container
</code></pre>

<p>Is there something that I am missing here?</p>

David Doe
<p>Maybe you need to fix your Dockerfile , and pay attention to the order of Docker instructions and some best practices.</p>

<pre><code>FROM openjdk:11-jre-slim
WORKDIR /dist
COPY dist/* .
EXPOSE 9000 9443

CMD ["/dist/bin/start","-Dhttps.port=9443"]
</code></pre>

<p>And first locally test this and make sure the required directory structure exists inside by execing into the container and do an <code>ls</code> </p>
