How to keep a docker container running some background processes

1k Views Asked by At

I have a python script that launches multiple programs in different screen sessions (gnu screen: terminal multiplexer) and exits.

The screen sessions keep running in the background.

Everything works fine when I run the script directly on my host machine.

Now, I dockerized the entire thing. But docker containers exit after the script finishes.

docker run -d myimage

After reading a bit, I realized that this is the normal behavior of docker. if no foreground process is running it will exit.

But I want to keep the docker container up, what should I do?

I saw, that running with -it flag, keeps it up. But I want to detach from the container, yet keep it up.

0

There are 0 best solutions below