Answers: <p>Though it's not advised to have multiple processes inside a container, but you have 2 options:</p>
  
  <p>Use a process manager like supervisord or wrapper script to use as CMD (meta code)</p>
  
  <pre><code>start_first_process_in_bg
  if START_FAILED
    exit
  start_second_process_in_bg
  if START_FAILED
    exit
  
  while sleep 5; do
    check_first_process
    check_second_process
  
    if ANY_PROCESS_FAILED; then
      exit
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2020-03-26T12:06:56.340Z
Answers: 2020-03-26T12:06:56.340Z
Answers: oryades
Body: <p>I have a Dockerfile with a CMD, it calls a .sh file that runs a Django app
  ( makemigrations, migrate and uwsgi )
  And that runs fine in a pod.</p>
  
  <p>There's a django admin script that runs infinitely that I'd like to run in the same pod.</p>
  
  <ul>
  <li>Per the docker docs I can't have a second command in the Dockerfile</li>
  <li>Adding the script on the sh file wouldn't work because the both processes ( the app or command script ) are running and don't end so the second one never runs.
  
  <ul>
  <li>If I go in the pod and run exec -it bash to manually run the script i can't leave the pod without killing the process (Ctrl-C) or can  I? </li>
  </ul></li>
  </ul>
  
  <p>Any suggestions?</p>
  
Tags: <dockerfile><kubectl>
Title: Running Two infinite commands on single pod/image
UserDisplayName: hvannia
ThreadText: # Running Two infinite commands on single pod/image
  
  (Asked by: username_0 on 2020-03-25)
  
  I have a Dockerfile with a CMD, it calls a .sh file that runs a Django app
  ( makemigrations, migrate and uwsgi )
  And that runs fine in a pod.
  
  There's a django admin script that runs infinitely that I'd like to run in the same pod.
  
  * Per the docker docs I can't have a second command in the Dockerfile
  * Adding the script on the sh file wouldn't work because the both processes ( the app or command script ) are running and don't end so the second one never runs.
    + If I go in the pod and run exec -it bash to manually run the script i can't leave the pod without killing the process (Ctrl-C) or can I?
  
  Any suggestions?
  
  **Tags:** dockerfile, kubectl
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-03-26. Score: 1
  
  Though it's not advised to have multiple processes inside a container, but you have 2 options:
  
  Use a process manager like supervisord or wrapper script to use as CMD (meta code)
  
  ```
  start_first_process_in_bg
  if START_FAILED
    exit
  start_second_process_in_bg
  if START_FAILED
    exit
  
  while sleep 5; do
    check_first_process
    check_second_process
  
    if ANY_PROCESS_FAILED; then
      exit
  
  ```
  
  
  ---
  
  