Docker-Compose Restart Policy

后端 未结 3 1022
长发绾君心
长发绾君心 2021-01-31 13:49

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 thi

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-31 13:50

    Version 2 supports restart policies, using the restart keyword, and should work fine for you if you don't need Swarm (which you said you don't need/want).

    version: '2'
    services:
      web:
        image: apache
        restart: always
    

    https://docs.docker.com/compose/compose-file/compose-file-v2/#restart

    Compose format version 3 has a parameter called restart_policy, but so far as I can tell from documentation it is only valid as part of deploy, which is only used when deploying to a Swarm. So version 3 is probably not useful in your case.

提交回复
热议问题