Hai semuanya di materi kali ini kita akan membahas tentang Docker Volume menggunakan Compose file, Diantaranya yang akan kita bahas yaitu

  1. Store data in volume
  2. Mount-Bind

Ok langsung aja kita ke pembahasan yang pertama yaitu

Store data in volume

Mount host paths or named volumes, specified as sub-options to a service.

But, if you want to reuse a volume across multiple services, then define a named volume in the top-level volumes key. Use named volumes with services, swarms, and stack files.

This example shows a named volume (pg_data) being used by the db service, or you can use long format compose like this


You can mount a host path as part of a definition for a single service, and there is no need to define it in the top level volumes key.

or you can use long format compose like this