Home > other >  Bash - why docker exec on exit kill nohup processes?
Bash - why docker exec on exit kill nohup processes?

Time:02-10

I have run the docker ubuntu container, there was only a bash script. I want to use the docker exec in the container to start my application:

Docker exec - it zero b3fc9dd35f2./main. Sh

In the main script I want to use nohup run another application, because this is a long-running application:

#!/bin/bash
Nohup./Java. Sh & amp;
# with this strange sleep the script is working
# sleep 1
Echo ` date ` finish main & gt;>/the status log

Java. Sh scripts as follows (for the sake of simplicity, it is a virtual script) :

#!/bin/bash
Sleep 10
Echo ` date ` finish Java & gt;>/the status log

Problem is in the docker exec return Java. Sh was killed immediately. The problem is why?
I found that the only solution is to nohup starts in the first script to add some virtual sleep 1. Better than the second process running. Do you know why?
[edit]
The second solution is to Java before sleep. Sh scripts to add some echo or the trap command. Than it is working properly. Unfortunately I can't use this solution instead of the script I have Java process.

CodePudding user response:

This is not the answer, but I still did not comment on the reputation.
I don't know why nohup doesn't work. But I use your idea to do a effective solution:

Docker exec - ti running_container bash - c 'nohup./main. Sh & amp;> The output & amp; Sleep 1 '

CodePudding user response:

Solution for:
Docker exec - d vessel name/bin/bash - c "script in the path"
  • Related