[Django]-Persistent Django's PostgreSQL database in Docker

3👍

The data persistance in docker can be tricky but here are 2 possible solutions :

  1. 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.
  2. 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 🙂

Leave a comment