<p>I am really new on this kind of stuff, new on Kubernetes and Docker, but already have some experience on Java.</p>

<p>I tried using Docker Hub by connecting it to GitHub.</p>

<p>On my Git-hub there are only 2 codes:</p>

<ol>
<li>Dockerfile</li>
<li>Simple hello world Java code.</li>
</ol>

<p>Every time I run it on Kubernetes and check it with kubectl get pods, I always get CrashLoopBackOff.</p>

<p>I don't understand what's the problem, I already check the code and try to run it on Docker and it works, it prints out hello world. But not on Kubernetes.</p>

<p>This is the code on Dockerfile</p>

<pre><code>FROM openjdk:8
COPY helloworld.java .
RUN javac helloworld.java
ENTRYPOINT ["java", "helloworld"]
</code></pre>

<p>This is the code on simple helloworld java</p>

<pre><code>public class helloworld {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}
</code></pre>

<p>What I expected is: as I run this on Kubernetes I hope it says that it's ready and I can deploy it to an IP and show simple hello world.</p>

newbielearner
<p>Since you didn't specify how you executed it, I will assume you've been using <code>kubectl run</code> (by default creates a deployment) or a manifest defining a deployment. If so, then the <code>CrashLoopBackOff</code> is expected because <a href="http://kubernetesbyexample.com/deployments/" rel="nofollow noreferrer">deployments</a> are for long-running processes. You Java code is not long-running. It prints something and then exits, that is, doesn't have an endless loop in there. </p>

<p>So either do the <code>System.out.println</code> in a loop (with a sleep inbetween?) or use a run command or a workload type (such as <a href="http://kubernetesbyexample.com/jobs/" rel="nofollow noreferrer">jobs</a>) that is for one-off execution.</p>

<p>BTW, even with deployments, you should still be able to use <a href="http://kubernetesbyexample.com/logging/" rel="nofollow noreferrer">kubectl logs</a> to see the output from the first execution.</p>
