<p>I am very new to docker Kubernetes. I have made my cluster of 3 nodes now I am creating a YAML file for pod creation. I have taken the image from <a href="https://github.com/utkudarilmaz/docker-hping3" rel="nofollow noreferrer">https://github.com/utkudarilmaz/docker-hping3</a> the image name is utkudarilmaz/hping3. Can someone help me to set the command or the docker file in the path? because I cannot understand the problem. I want to run my pod successfully working so, that I can utilize it.
My YAML file like</p>
<pre><code>---
 apiVersion: v1
 kind: Pod
 metadata:
   name: second
   labels:
     app: web
 spec:
   containers:
     - name:  hping3
       image: utkudarilmaz/hping3
       command: [&quot;hping3 [IP_ADDRESS&quot;]
       ports:
         - containerPort: 80
   nodeSelector:
       disktype: ssd
</code></pre>
<p>if I do not specify [command] my pod status is CrashLoopBackOff. I have searched and found that <a href="https://stackoverflow.com/questions/41604499/my-kubernetes-pods-keep-crashing-with-crashloopbackoff-but-i-cant-find-any-lo">My kubernetes pods keep crashing with &quot;CrashLoopBackOff&quot; but I can&#39;t find any log</a>
I need a command to run the container continuously otherwise it goes in the cycle if I specify a command in YAML file like an above command: [&quot;hping3 103.22.221.59&quot;] and then when I run</p>
<pre><code>kubectl exec –it second – hping3 [IP_ADDRESS]
</code></pre>
<p>I get</p>
<pre><code>error: unable to upgrade connection: container not found (&quot;hping3&quot;)
</code></pre>
<p>the output of kubectl decribe pod second</p>
<pre><code>Events:
  Type     Reason     Age                   From               Message
  ----     ------     ----                  ----               -------
  Normal   Scheduled  3m39s                 default-scheduler  Successfully assigned default/second1 to netcs
  Normal   Pulled     3m35s                 kubelet            Successfully pulled image &quot;utkudarilmaz/hping3&quot; in 2.714028668s
  Normal   Pulled     3m31s                 kubelet            Successfully pulled image &quot;utkudarilmaz/hping3&quot; in 2.734426606s
  Normal   Pulled     3m15s                 kubelet            Successfully pulled image &quot;utkudarilmaz/hping3&quot; in 2.61256593s
  Normal   Pulled     2m46s                 kubelet            Successfully pulled image &quot;utkudarilmaz/hping3&quot; in 2.65727147s
  Warning  BackOff    2m11s (x5 over 3m4s)  kubelet            Back-off restarting failed container
  Normal   Pulling    2m4s (x5 over 3m38s)  kubelet            Pulling image &quot;utkudarilmaz/hping3&quot;
  Normal   Created    119s (x5 over 3m35s)  kubelet            Created container hping3
Warning  Failed     119s (x5 over 3m35s)  kubelet            Error: failed to start container &quot;hping3&quot;: Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: &quot;hping3 103.22.221.59&quot;: executable file not found in $PATH: unknown


  Normal   Pulled     119s                  kubelet            Successfully pulled image &quot;utkudarilmaz/hping3&quot; in 5.128803062s

</code></pre>
<p>Some Output of docker inspect $utkudarilmaz/hping3</p>
<pre><code>
&quot;Mounts&quot;: [],
        &quot;Config&quot;: {
            &quot;Hostname&quot;: &quot;104e9920881b&quot;,
            &quot;Domainname&quot;: &quot;&quot;,
            &quot;User&quot;: &quot;&quot;,
            &quot;AttachStdin&quot;: false,
            &quot;AttachStdout&quot;: false,
            &quot;AttachStderr&quot;: false,
            &quot;Tty&quot;: true,
            &quot;OpenStdin&quot;: false,
            &quot;StdinOnce&quot;: false,
            &quot;Env&quot;: [
                &quot;PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot;
            ],
            &quot;Cmd&quot;: null,
            &quot;Image&quot;: &quot;utkudarilmaz/hping3&quot;,
            &quot;Volumes&quot;: null,
            &quot;WorkingDir&quot;: &quot;&quot;,
            &quot;Entrypoint&quot;: [
                &quot;hping3&quot;
            ],
            &quot;OnBuild&quot;: null,
            &quot;Labels&quot;: {
                &quot;desription&quot;: &quot;hping3 tool building on Alpine:latest&quot;,
                &quot;version&quot;: &quot;1.0&quot;

</code></pre>
<p>my container will not continue running
when I try this command</p>
<pre><code>command: [ &quot;/bin/bash&quot;, &quot;-c&quot;, &quot;--&quot; ]
    args: [ &quot;while true; do sleep 30; done;&quot; ] from 
https://stackoverflow.com/questions/31870222/how-can-i-keep-a-container-running-on-kubernetes/40093356
</code></pre>
<p>same error file not found in the path</p>

goody
<p>First of all, you don't need to specify <code>containerPort</code> here as there is nothing listening on any tcp port in your <code>hping3</code> container:</p>
<pre><code>$ kubectl exec -ti second -- /bin/sh                                                                               
/ # netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
</code></pre>
<p>In fact you don't even need to provide any <code>command</code> as <code>hping3</code> is already defined as an <code>ENTRYPOINT</code> in this docker image and you don't really need to overwrite it. All you need in order to run your <code>hping3</code> <code>Pod</code> is the following yaml manifest:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: second
spec:
  containers:
    - name:  hping3
      image: utkudarilmaz/hping3
      args: [&quot;IP-address&quot;]
</code></pre>
<p>Yes, providing some <code>args</code> is obligatory in this case, otherwise your container will fall into <code>CrashLoopBackOff</code> state.</p>
<p>As you can read in the very brief description of the image in its <a href="https://github.com/utkudarilmaz/docker-hping3#docker-hping3" rel="noreferrer">README.md</a>:</p>
<blockquote>
<p><strong>Usage:</strong></p>
<pre><code>docker pull utkudarilmaz/hping3:latest
docker run utkudarilmaz/hping3:latest [parameters] target_ip
</code></pre>
</blockquote>
<p>providing <code>target_ip</code> is obligatory, but you don't have to provide anything else.</p>
<p>Although the above usage description doesn't say anything about running this image on <strong>kubernetes</strong>, such short description should be totally enough for us and we should be able to translate it &quot;from <strong>docker</strong> to <strong>kubernetes</strong> language&quot;.</p>
<p>Take a look at the following section, titled <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/" rel="noreferrer">Define a Command and Arguments for a Container</a>, in the official <strong>kubernetes</strong> docs, especially <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#notes" rel="noreferrer">this</a> fragment:</p>
<blockquote>
<p><a href="https://i.stack.imgur.com/Rv9Jw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Rv9Jw.png" alt="enter image description here" /></a></p>
<p>When you override the default Entrypoint and Cmd, these rules apply:</p>
<ul>
<li><p>If you do not supply  <code>command</code>  or  <code>args</code>  for a Container, the defaults defined in the Docker image are used.</p>
</li>
<li><p>If you supply a  <code>command</code>  but no  <code>args</code>  for a Container, only the supplied  <code>command</code>  is used. The default EntryPoint and the
default Cmd defined in the Docker image are ignored.</p>
</li>
<li><p>If you supply only  <code>args</code>  for a Container, the default Entrypoint defined in the Docker image is run with the  <code>args</code>  that
you supplied.</p>
</li>
<li><p>If you supply a  <code>command</code>  and  <code>args</code>, the default Entrypoint and the default Cmd defined in the Docker image are ignored. Your
<code>command</code>  is run with your  <code>args</code>.</p>
</li>
</ul>
</blockquote>
<p>From the above we are particularly interested in the third point:</p>
<blockquote>
<ul>
<li>If you supply only  <code>args</code>  for a Container, the default Entrypoint defined in the Docker image is run with the  <code>args</code>  that
you supplied.</li>
</ul>
</blockquote>
<p>which means that in our <strong>kubernetes</strong> <code>Pod</code> definition we may supply only <code>args</code> and it's totally fine. As the <code>ENTRYPOINT</code> is already defined in the <code>utkudarilmaz/hping3</code> image, there is no need to overwrite it by defining a <code>command</code>.</p>
<p>I was able to reproduce the error messsage you get only when trying to connect to <code>hping3</code> container in <code>CrashLoopBackOff</code> state:</p>
<pre><code>$ kubectl exec -ti second -- hping3 [IP-address]                                                                  
error: unable to upgrade connection: container not found (&quot;hping3&quot;)
</code></pre>
<p>But when it runs, <code>kubectl exec</code> works without any issues:</p>
<pre><code>$ kubectl exec -ti second -- hping3 [IP-address]
HPING [IP-address] (eth0 [IP-address]): NO FLAGS are set, 40 headers + 0 data bytes
</code></pre>
<p>Btw. hyphens in your command look a bit strange and they are not exactly the same characters as <code>-</code> and are not interpreted correctly when copied from the code snippet in your question, leading to strange errors like the following:</p>
<pre><code>Error from server (NotFound): pods &quot;–it&quot; not found
</code></pre>
<p>So please mind the exact characters that you use in your commands.</p>
<p>As to the explanation of the error message you see when you <code>kubectl describe</code> your <code>Pod</code>:</p>
<pre><code>&quot;hping3 [IP-address]&quot;: executable file not found in $PATH: unknown
</code></pre>
<p>it says clearly that an executable named &quot;hping3 [IP-address]&quot; (yes, name of a single file!) cannot be found in your <code>$PATH</code> and I'm sure you don't have executable with such name 😉</p>
<p>If you provide a <code>command</code> this way:</p>
<pre><code>command: [&quot;hping3 [IP-address]&quot;]
</code></pre>
<p>keep in mind that the whole string between the double quotes is interpreted as a single command / executable. That's why it was trying to look for executable file named &quot;hping3 [IP-address]&quot; but for obvious reasons it couldn't find it.</p>
<p>As already mentioned in comments, the correct usage of the <code>command</code> field can be:</p>
<pre><code>command: [&quot;hping3&quot;,&quot;[IP-address]&quot;]
</code></pre>
<p>but in your case you don't really need it.</p>
<p>I hope the above explanation was helpful.</p>
