The VOLUMES Instruction

A volume can also be automatically created by a Dockerfile with the VOLUME instruction. This is beneficial for containers that require volumes in order to run properly, like a postgresql database.

In your Dockerfile you can insert a command similar to this one:

VOLUME /var/lib/postgresql/data