Docker -- restart service if node app crashes

Viewed 769

I have a dockerized nodejs service which unfortunatly due to 3rd party modules used keeps crashing randomly like once or twice per day. The problem is I need to have that service up all the time. I tried to use the "restart" option in my compose file, but it doesn't do anything.

Is there anything I am doing wrong, or missed in order to restart the docker container if the node process crashes?

Here is my compose snippet

version: "3"
services:
  api:
    env_file:
      - .env
    build:
      context: .
    ports:
      - '5000:5000'
    depends_on: 
      - postgres

    networks:
      - postgres
    
    restart: always
0 Answers
Related