Using Docker Compose v3, it's possible to define a Docker deployment along with production details. This provides a central location for managing your application deployments that can be deployed onto a Swarm Mode cluster.
A Docker Compose file has been created that defines deploying a Redis server with a web front end.
View the file using cat docker-compose.yml
The file has been extended to utilize Swarm deployment options.
The first configuration option uses depends_on. This states that Redis must be deployed before the web and allows us to control the order of services being started.
The next configuration options define how the application should be deployed using the new deploy options.
Firstly, mode: replicated and replicas: 2 determine how many replicas of the service should be started.
Secondly, resources are define. The limits are hard limits that the application cannot exceed, the reservations is a guide to Docker Swarm to indicate the resources the applications requires.
Third, restart_policy indicates what should happen if the process crashes.
Fourth, update_config defines how updates should be applied and rolled out.
Finally, placement allows us to add constraints to determine where the service should be deployed.
More details can be found at https://docs.docker.com/compose/compose-file/#deploy