Declaring Docker volumes on Compose files
We’ve been able to create a Docker volume and use it, and had a look at its features. The step next is to create and use volumes using Compose. Volumes on Compose are defined in the volumes
sections:
services: nginx: image: nginx volumes: example-compose-volume:
The configuration option on volumes
can apply to example labels:
services: nginx: image: nginx volumes: example-compose-volume: labels: - com.packtpub.compose.app=volume-example
Alternatively, you can have more advanced configurations, for example, a driver that is configured to use nfs
:
services: volumes: nfsvol: driver_opts: type: "nfs" o: "addr=127.0.0.1,nolock,rw" ...