How to create a persistent data volume for Postgres Database container within a Docker project?

I have a docker project running in a droplet with a Postgres Container. As the container is ephemeral and can disappear when the droplet goes away, I want to attach a persistent volume so the database is separate from the droplet. Is this the right way to go about this? I have looked for a tutorial but I can’t seem to find it.

What is the right way to approach a persistent database(like RDS on AWS) that is separate from the droplet?