Docker-Compose Restart Policy

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?

  • How to deploy Dockerfile and application files to boot2docker
  • How to enable docker API to access via http
  • Bluemix Dev Ops: Building a project with private git submodules
  • Is there a way to make docker containers truly fault-tolerant?
  • Use ehcache for application deployed via docker against the stateless rule
  • How to handle stage specific keystore in docker images
  • Error making http request across linked Docker containers
  • Hide/obfuscate environmental parameters in docker
  • docker-runc not installed on system
  • cannot access Docker remote registry
  • SSHFS Mount for Docker Container / Node Server needs to access files on an external server
  • Play framework running inside docker not accessible from localhost
  • 2 Solutions collect form web for “Docker-Compose Restart Policy”

    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'
        image: apache
        restart: always

    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.

    It’s looks like a gap in documentation

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

    version: '3'
        restart: on-failure:5 
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.