Using Docker Compose, how do you define that a service should be restarted after a failure?

Experience Level: Senior
Tags: Docker Compose

Answer

Add the restart: property to your service definition:

version: "3.9"
services:
  web:
    image: mysql:5.7
    restarts: always

Comments

No Comments Yet.
Be the first to tell us what you think.
Docker Compose
Docker Compose

Are you learning Docker Compose ? Try our test we designed to help you progress faster.

Test yourself