-1

I have a process in an Ubuntu docker container. If it crashes, I want to restart it automatically. What is the best way to go about it? I checked systemd (which is the normal Linux method) but docker doesn't support it. inittab is also deprecated.

Swami
  • 135
  • 2
  • 10

1 Answers1

1

Docker offers such functionality, all you have to do is to define a restart policy for the container.

You should choose one of the available policies no,always,on-failure,unless-stopped and adjust your docker run command accordingly.

From docs:

To configure the restart policy for a container, use the --restart flag when using the docker run command

For your case, choose one of always or on-failure.

Note: The above is valid only if the process you have mentioned is the container's entrypoint.

leopal
  • 4,711
  • 1
  • 25
  • 35