This is a pseudo-exert from one of my docker-compose files (actually, it’s the generated docker-compose from something I setup in the Rancher UI)
version: '2'
volumes:
jenkins-server-volume:
external: true
driver: rancher-nfs
services:
jenkins-server:
image: jenkins:2.7.4
stdin_open: true
volumes:
- jenkins-server-volume:/var/jenkins_home
tty: true
ports:
- 8080:8080/tcp
- 50000:50000/tcp
labels:
io.rancher.scheduler.affinity:host_label: subnet=private
io.rancher.container.hostname_override: container_name
In this case, the persistent volume I setup int he Rancher UI was named “jenkins-server-volume”. It’s identified in the “volumes” section, and then used in the “services” section. I’m not a docker-compose expert yet, so there may be a more straightforward approach. This is all described in more detail and with different examples for the different scopes here: https://docs.rancher.com/rancher/v1.2/en/rancher-services/storage-service/
To answer your last question… I’m sure there are a dozen ways to view/verify the volume contents, but I just went to Infrastructure->Hosts in the Rancher UI, picked a host and selected “Add Container”. I then started a super basic no-frills ubuntu container and added the storage volume to it and some simple location like “/verify”. I then start the container, and again using the Rancher UI, “Execute a Shell” on it. I can then look in the “/verify” directory and I should see the contents of the volume. You can even start a second container in exactly the same way and connect the same volume. Then add or modify some data in one container and then look in the directory in the second container and make sure the data you added or changed was persisted.