<p>In this official document, it can run command in a yaml config file:</p>

<blockquote>
  <p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/" rel="noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/</a></p>
</blockquote>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: hello-world
spec:  # specification of the pod’s contents
  restartPolicy: Never
  containers:
  - name: hello
    image: "ubuntu:14.04"
    env:
    - name: MESSAGE
      value: "hello world"
    command: ["/bin/sh","-c"]
    args: ["/bin/echo \"${MESSAGE}\""]
</code></pre>

<p>If I want to run more than one command, how to do?</p>

<pre><code>command: ["/bin/sh","-c"]
args: ["command one; command two &amp;&amp; command three"]
</code></pre>

<p><strong>Explanation:</strong> The <code>command ["/bin/sh", "-c"]</code> says "run a shell, and execute the following instructions". The args are then passed as commands to the shell. In shell scripting a semicolon separates commands, and <code>&amp;&amp;</code> conditionally runs the following command if the first succeed. In the above example, it always runs <code>command one</code> followed by <code>command two</code>, and only runs <code>command three</code> if <code>command two</code> succeeded.</p>

<p><strong>Alternative:</strong> In many cases, some of the commands you want to run are probably setting up the final command to run. In this case, building your own <a href="https://docs.docker.com/v1.8/reference/builder/">Dockerfile</a> is the way to go. Look at the <a href="https://docs.docker.com/v1.8/reference/builder/#run">RUN</a> directive in particular.</p>
