Moritz Vogt
Moritz Vogt

Reputation: 159

Choose restart policy for my services in the docker-compose file

I´m having troube selecting the restart policy for my Services.

My Application needs two Containers to run.

My Questions:

Does anyone have Experience with choosing the restart policy?

Do I need to have the same restart Policy for both of my services?

I would straight forward choose the on-failure policy. When something crashes in the container it should immediately startup back again.

Offical Docker Documentation: https://docs.docker.com/config/containers/start-containers-automatically/#:~:text=Restart%20policy%20details,-Keep%20the%20following&text=A%20restart%20policy%20only%20takes,going%20into%20a%20restart%20loop.

Upvotes: 1

Views: 1056

Answers (1)

abestrad
abestrad

Reputation: 906

We have tried on-failure and that based on particular needs for some projects and services.

I think all depends on your needs. Have you consider what are your needs? Some questions here:

  1. Do you need the linked containers are start in the correct order?

Restart policies ensure that linked containers are started in the correct order.

  1. Are you planning to use a process manager to start containers?

Docker recommends that you use restart policies, and avoid using process managers to start containers.

  1. Have you try to experiment with all the policies and determine the policy that covers what you project needs?
  • on-failure[:max-retries]
  • always
  • unless-stopped

Upvotes: 2

Related Questions