Skip to content

Instantly share code, notes, and snippets.

@drmalex07
Last active February 11, 2020 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drmalex07/9e5885177c3766227099833892e0748f to your computer and use it in GitHub Desktop.
Save drmalex07/9e5885177c3766227099833892e0748f to your computer and use it in GitHub Desktop.
An example creating a Docker volume on NFS. #docker #nfs #docker-volumes

Readme - Create a Docker volume on NFS

In this example, we directly instruct Docker to maintain a volume backed by NFS storage. Another way, of course, is to mount the NFS folder at the system level (afterwards, any container can bind-mount it).

By adding a Docker volume backed by NFS, Docker engine will take care of mounting/unmounting based on how containers are using this volume.

See also this comment:

Create the volume:

docker volume create -d "local" \
     -o 'type=nfs' -o 'device=:/var/local/nfs/share' -o 'o=addr=nfs.example.net,rw,nfsvers=4,async' "nfs-share-1"

Use named volume in a container:

docker run -it --rm --mount "type=volume,source=nfs-share-1,target=/data" --name "test-1" debian:9 bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment