-2

I have postgres database with stored data. Now i want to change my application to run in a container and reading from earlier stored data in postgres database. But how to create volume with already stored data? A don't want to lose any data. How to achieve it?

piccolo
  • 3
  • 1
  • Same as migrating with another physical postgres database. Nothing specific about docker here. You should post another question without mention of docker. – Blusky Dec 21 '18 at 21:04

1 Answers1

0

Better to use pg_dump https://postgrespro.com/docs/postgresql/9.6/app-pgdump

You need to dump a database to file at first

pg_dump mydb > db.sql

After your container is running you need to restore this data from file as

psql -d newdb -f db.sql
Maxim
  • 2,233
  • 6
  • 16