3👍
The data persistance in docker can be tricky but here are 2 possible solutions :
- Don’t worry, docker will handle it. In your case, since you are usinng a compose file, as long as you do not clean your volumes and that you stop your docker compose with a ‘docker-compose down’ there should be no issues. Once you will use a ‘docker-compose up’ your data should still be on the database.
- You want more control (and maybe share easely the data). In that case you can choose to manualy mount a file in which your data will be stored. For that you can learn more here (at the bottom of the page). Tips :
volumes:
- /my/own/datadir:/var/lib/postgresql/data
I hope that aswer your question 🙂
Source:stackexchange.com