Here at IbmiMedia, we have received many support request regarding such Docker container not responding immediately after start.
We have helped customers to solve Docker related problems as part of our Server Support Services for Linux, Webmin, Virtualmin and Cpanel users.
In this context you will see the causes of such errors and how we solved it.
Why does a Docker container dies immediately after start?
A bug free Docker is suppose to exit its processes automatically after completion.
For the process to continue to run, a function must be active. In some cases, process managers such as supervisord or runit can make a process to remain active.
If a Docker container is not running any process, it will shut down because it will no longer be active.
How to solve a Docker which dies immediately after starting
To keep Docker running, you can assign a special command as seen below at the end of the script;
wait [n ...]
The wait command is very effective in that it helps to keep the container active by forcing the current processed to wait for each other and after successfully executing, it terminates.
Alternatively, you can add the following code to the end of the script;
while true; do sleep 1000; done
Do you need support in fixing Docker errors? We will solve it.