Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker-Compose Restart Policy

Tags:

docker

I looked thru the docs for docker-compose and I see that Version 3 has a deploy restart policy but it's only for swarm. I tried setting restart_policy on my service but got this error:

ERROR: The Compose file './docker-compose.yml' is invalid because: Unsupported config option for services.web: 'restart_policy' 

Is there any way to set a restart policy on services created using docker-compose outside of a swarm?

like image 325
Ken J Avatar asked Feb 14 '17 00:02

Ken J


People also ask

What is docker restart policy?

Docker provides restart policies to control whether your containers start automatically when they exit, or when Docker restarts. Restart policies ensure that linked containers are started in the correct order. Docker recommends that you use restart policies, and avoid using process managers to start containers.

How do I check my container restart policy?

Users can type docker ps to check if the restart policy is active; it will be shown as either Up , when the container is up and running, or Restarting when the container is in the restart state.

Does Docker compose up restart container?

The docker compose start command is useful only to restart containers that were previously created, but were stopped. It never creates new containers.


1 Answers

It looks like a gap in the documentation

In 3rd version, we can still use "restart" inside services same as before in v.2 (except for deploy into swarm)

version: '3' services:   my-service:     restart: on-failure:5  

https://docs.docker.com/compose/compose-file/compose-file-v3/#restart_policy

like image 99
Alexandr Latushkin Avatar answered Oct 26 '22 15:10

Alexandr Latushkin