[GDD] Stateful Services 10 December 2018

There is still one more small change when running locally vs. running in a cloud environment like AWS that was beyond the scope of getting our Node app running, but also important.
 
The configuration we tested out for MongoDB earlier would need one small change if we wanted our volumes to actual persist in the cloud.
 
The way we last configured them with volumes.. They would work... but probably not for long.
 
We need to specify a volume plugin to use when we are using a cloud provider, so they are actually persisted.
 
This plugin tells AWS or wherever you are running HOW to create a volume using their available infrastructure.
 
When we set up Docker For AWS we clicked a box about Cloudstor - this is the volume driver.
 
Cloudstor use EFS, a network volume, by default. EBS can be specified as well, and should be for write or read heavy services.
 
Depending on the throughput on MongoDB in our example stack, EBS might be a better choice. We will use EFS as it's the default.
 
Back in our split testing application we made a file stack.yml
 
Let’s make another, just for demonstration purposes called db.yml
 
version: '3.4'

networks:
 
  mongo:
 
services:
 
  mymongodb:
    image: mongo
    networks:
      - mongo
    volumes:
      - mongo-data:/data/db
 
volumes:
  mongo-data:
    driver: cloudstor:aws
    external: false
 
Notice the driver option specified as cloudstor:aws .

This is all that’s needed to configure the plugin when using cloudstor with Docker for AWS!  
 
There are other options for Docker Swarm as well, such as RexRay, and more options available for cloudstor as well, so feel free to check them out!
 
Patrick “Cloud Storer” Scott