If you want to use -d to run in the background, you can currently only use the command that can run continuously, otherwise it will stop when the operation is completed.
I don’t particularly understand your scenario. I see that you have asked several docker-related questions. I will give you a few commands for your reference. I hope they are useful to you.
Run a continuous output task in DockerFile Okay, this is almost an infinite loop
docker ps -a
Here you can see the running status of docker, up means it keeps running, and exit means it exits after it finishes running. Docker will exit when it finishes running the task you want it to perform. So you have to write a continuous Command
Even if -d is added, as long as the command is finished, docker will think that it has nothing to do, so it will automatically exit. To make the container run in the background, it is necessary to have a foreground process. You can add top, tail, etc. after the command to always be in the foreground. Running process
Let me go, everyone upstairs did not understand what the original poster meant. . . What he means is that there is no continuous running inside docker (i.e. running in the background). If you want docker to keep running without exiting, you can use supervisord
-d parameter is to keep docker running in the background,
If your run command can run continuously and cannot be stopped after running like ls, then just add -d
If you want to use -d to run in the background, you can currently only use the command that can run continuously, otherwise it will stop when the operation is completed.
I don’t particularly understand your scenario. I see that you have asked several docker-related questions. I will give you a few commands for your reference. I hope they are useful to you.
You can just run a program in the foreground, or use supervisor to manage running programs
You can do this
Run a continuous output task in DockerFile
Okay, this is almost an infinite loop
Here you can see the running status of docker, up means it keeps running, and exit means it exits after it finishes running. Docker will exit when it finishes running the task you want it to perform. So you have to write a continuous Command
Even if -d is added, as long as the command is finished, docker will think that it has nothing to do, so it will automatically exit. To make the container run in the background, it is necessary to have a foreground process.
You can add top, tail, etc. after the command to always be in the foreground. Running process
Let me go, everyone upstairs did not understand what the original poster meant. . . What he means is that there is no continuous running inside docker (i.e. running in the background).
If you want docker to keep running without exiting, you can use supervisord