Postgresql 宿主机如何与Docker同步数据?
大家讲道理
大家讲道理 2017-04-27 09:01:44
0
3
651

我想到以下两个方法:

使用-v参数同步data文件

执行时,没找到data文件,查了postgresql.conf,说在/var/lib/postgresql/9.5/main但是看了文件大小很小,而我的数据很大。

而且我猜测是否可以这样做,直接同步data文件达到数据同步。

通过-p 5432,使Docker在增删改查时都采用宿主机数据库?

执行时 -p参数时,报错5432已被占用, 因为我的其他程序在访问数据库。

我该怎么做,让Docker的数据和主机数据实时同步。

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(3)
刘奇

It is recommended to read Docker’s official documentation or introductory tutorial.
There is no concept of synchronization between the container and the host.

世界只因有你

Can’t two database instances use the same data file? I’ve never seen a database that can do this....

I don’t understand the second way....

PS: If you really want to [synchronize the database of the host and docker. You can form a cluster... This is the way I can think of...

淡淡烟草味

Method 2:
If you want to use the application in Docker on the host postgres, you can use the public network to directly access the host’s public IP and the corresponding port

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!