Skip to content

Latest commit

 

History

History
25 lines (14 loc) · 1.3 KB

File metadata and controls

25 lines (14 loc) · 1.3 KB

Docker related recommendations

Advices

Apply restart policies

Usually, containers are associated with daemon processes. The container life-cycle is determined by the daemon status, i.e.: you start a container with a daemon and when the daemon exits, the container also stop.

As a result, it is common to deploy containerized applications with something that monitor the container status and re-launch it if it fails. In docker, a way to do this is the native restart policies feature.

This let you specify if a container should be re-launched never, when exit on error or always.

Unless your container is a data-only container or a one-shot app, the better is to choose always.

Since in CloudOpting we are using the docker-compose yaml specification, this can be done with the restart directive:

containername:
  image: reponame/imageservice
  restart: always

This way, each time the daemon inside the container stops (no matter why) or the VM is restarted, the application will be stated automatically.