There is a docker container, Postgress is in it. All this is used for tests and works very slowly. Is it possible to zatyunit database so that it is completely in memory and will not prevent the container to this?
- This is doable . Although it looks very bizarre, since there is no solution built into the post-grease. - D-side
|
1 answer
You can simply create a ramdisk in the system and store data on it, postgres will not even notice the trick:
sudo mkdir /mnt/ramdisk sudo mount -t tmpfs -o size=512m tmpfs /mnt/ramdisk docker run -d -v /mnt/ramdisk:/var/lib/postgresql/data postgres On my machine, it started successfully and created a table through generate_series.
NB: This method should not be used for permanent storage because of the high risk of losing data.
- According to the link above, they write that as soon as the existing instance ramdisk is re-created, the postgres will refuse to start, because the database cluster will be damaged. For disposable docker containers that are removed after stopping, this is ok. It is worth noting this detail in the answer. - D-side
- @D-side here it seems, and so the whole context speaks about it. Added by. - etki
- oneI mean, if you stop and start a container with such a database, it may not start . The fact that the data will fly away, and so it is clear. - D-side
|