D
D
Dmitry Gavrilenko2017-04-19 21:49:51
linux
Dmitry Gavrilenko, 2017-04-19 21:49:51

How to keep track of the state inside a Docker container?

There is some kind of executable program that runs in a Docker container. This program acts as a kind of service that does something. How to know the status of this program in the container itself? Is it up and running or has it fallen and the container just hangs and nothing happens in it? How to start it again without restarting the container, and even in automatic mode? These are the things that are interesting. Tell me, please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2017-04-20
@Maddox

You should create a Docker container in such a way that it has one key process (which will have PID 0) running in it, the termination of which means the termination of the container. The exit code of this process will be the exit code of the container. You can see it in the output of `docker ps --all`. Read more here: each-container-should-have-only-one-concern . This does not mean that there should be only one process in the container, but there should be one such process, the life cycle of which is inextricably linked with the life cycle of the container.
This process should write logs to STDOUT and STDERR - then you can see them using `docker logs` and redirect them to the right place using the logging driver configured in the Docker daemon. Read more here: View a container's logs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question