I have a docker ubuntu container with only a bash script inside. I want to run the application in this container using docker exec as follows:
docker exec -it 0b3fc9dd35f2 ./main.sh
Inside the main script I want to run another application with nohup, as this is a long application:
#!/bin/bash nohup ./java.sh &
The java.sh script looks like this (for simplicity, this is a dummy script):
#!/bin/bash sleep 10 echo `date` finish java >> /status.log
The problem is that java.sh gets killed right after docker exec returns. The question is why?
The only solution I discovered was to add a dummy sleep 1 to the first script after running nohup. Than the second process is working fine. Do you have any idea why this is so?
[EDIT]
The second solution is to add the echo or trap java.sh to the java.sh script before bedtime. How does it work. Unfortunately, I cannot use this workaround, instead of this script I have a Java process.
source share