Hristo Hristov
Hristo Hristov

Reputation: 4151

When does a docker container stop?

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:

Can you please also point to the docs?

Thanks!

Upvotes: 4

Views: 1973

Answers (1)

Javier Cortejoso
Javier Cortejoso

Reputation: 9176

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.

Upvotes: 7

Related Questions