How does Postgresql host synchronize data with Docker?

  docker, question

I think of the following two methods:

Synchronize data files with the -v parameter

During the execution, the data file was not found and checkedpostgresql.conf, said in/var/lib/postgresql/9.5/mainBut the file size is very small, and my data is very large.

And I guess whether it is possible to do this and synchronize the data files directly to achieve data synchronization.

via-p 5432To make Docker use the host database when adding, deleting, modifying and checking?

At the time of execution-pParameter, an error was reported5432Already occupied because my other programs are accessing the database.

What should I do to synchronize Docker’s data with the host data in real time?

Can’t two database instances use the same data file? I have never seen such a database before. ….

The second way is not understood ….

PS: If you really want to synchronize the host database with docker, you can form a cluster … This is the way I can think of. ….