-
Go to the directory with docker-compose file.
-
Execute the next command to get db dump (note that the next command is an example for actual docker-compose config):
docker-compose run postgres pg_dump -h postgres -U postgres db_development > db_development.dump
- In case you already have an existent db:
docker-compose run <volume> bundle exec rake db:drop
- Create the db:
docker-compose run <volume> bundle exec rake db:create
- Import the dump to the postgres volume:
cat <dump> | docker-compose run postgres psql -h postgres -U postgres -d <db_name>
or, for native compressed sql files
docker-compose run postgres pg_restore -U postgres -h postgres --verbose -d db_development --clean < dumpfile.sql