If there is a simple run command specified on the command line, or with CMD, the container stops when the program exits. But, what if:
the program spawns new processes, ant then exits?
'exec' is used on the command line, then the first command exits?
Can you please also point to the docs?
Thanks!
The process you run when you exec docker run
will be the process with PID 1 (inside the process namespace of the container). This process is special in UNIX / Linux systems and it's the process in charge of 'adopting' any 'orphaned' process. If this process ends, all the processes will end also.
So, answering your questions, if this initial process (the one executed in docker run
) ends, all the processes inside your container will also end . I have not found any official documentation related to this, but there is a great post from phusion discussing about this topic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With