<p>Im using docker to run container app A, When i upgrade version of container app A i will upgrade remote db using pgsql with image postgres.</p>
<p>In k8s, i use init container to init images posgres and run script update.sh =&gt; If process successfully then run the container app A.</p>
<p>With docker environment, i wonder how to do that same with k8s?</p>
<p>#this problem has been solved, i using command into k8s resource and it work</p>
<pre><code>- name: main-container
...
  command:
  - bash
  - -c
  args:
  - |
     if [ -f /tmp/update_success ]; then
         do
     else
         # Update failed
         do somethingelse
     done
</code></pre>

Đặng Lực
<p>You would probably get a better answer if you posted your initContainer, but I would do something like this:</p>
<pre><code>initContainers:
- name: init
...
  command:
  - bash
  - -c
  args:
  - |
     update.sh &amp;&amp; touch /tmp/update_success
  volumeMounts:
  - name: tmp
    mountPath: /tmp
containers:
- name: main-container
...
  command:
  - bash
  - -c
  args:
  - |
     if [ -f /tmp/update_success ]; then
         # Update succeeded
         do_whatever
     else
         # Update failed
         do_something_else
     done
  volumeMounts:
  - name: tmp
    mountPath: /tmp
volumes:
- name: tmp
  emptyDir: {}
</code></pre>
<p>Also, if your init container exits non-zero, the main container will not run. If that's what you want, just make sure update.sh exits an error code when the update fails, and you don't need the above.</p>
