Changing Docker Storage Driver

For anyone interested I was able to change the service definition for docker and restart the daemon such that it uses overlay2:

- run:
    name: Switch to overlay2 storage driver
    # Edit docker service file to use overlay2 instead of aufs
    command: |
      ssh remote-docker \<< EOF
        sudo sed -i 's/aufs/overlay2/' /etc/systemd/system/docker.service.d/10-machine.conf
        sudo systemctl daemon-reload
        sudo systemctl restart docker.service
      EOF

The name/path of this may not be reliable, so I tried adding a daemon.json file at /etc/docker/daemon.json instead with the following command:

- run:
    name: Switch to overlay2 storage driver
    command: |
      ssh remote-docker \<< EOF
        echo '{"storage-driver":"overlay2"}' | sudo tee /etc/docker/daemon.json
        sudo systemctl daemon-reload
        sudo systemctl restart docker.service
      EOF

The above works, but because the service definition at /etc/systemd/system/docker.service.d/10-machine.conf includes --storage-driver aufs I saw that an error was being thrown on start up. So one way or another you need to remove/change the storage-driver flag from the service definition.