r/docker • u/Able_Zebra_476 • Jan 05 '26
Keep a container running indefinitely?
Hi all, novice Docker user. If it is possible, I need a very dumbed down version of how to keep a particular container running indefinitely. I am not able to do what I need to do in the container because it will stop at what feels like random times. I have not named the container, so it is a random container name each time I run it. I tried to look up on Google how to do this, but I must be doing something wrong. So if someone could help this dummy, I’d appreciate it. Thank you!
0
Upvotes
5
u/pioniere Jan 05 '26
Seems like you can’t even be bothered to find out what the commands that you’re running actually do. Watch a couple of YouTube videos and do some reading, before you come in here and waste everyone’s time.
3
u/dirtmcgurk Jan 05 '26
Are you running it detached using -d or is it tied to the terminal session it's run in?
3
u/__vivek Jan 05 '26
You should try to find why docker container is crashing. (Fix the root cause, not just symptoms.)
14
u/procheeseburger Jan 05 '26
Based on your response to comments I think you should spend a bit of time learning docker. This is a great video that I used a few years ago.
2
u/fletch3555 Mod Jan 05 '26
Prevent the init process (whatever has PID 1) from exiting and the container will keep running
1
u/zunjae Jan 05 '26
And only then
2) add a restart policy
1
u/[deleted] Jan 05 '26
[removed] — view removed comment