Django uses SQLite database by default, now we want to switch it to postgreSQL. Firstly, we fetch postgreSQL docker image and start an instance
1 | docker pull postgres |
The docker instance name can be whatever you want, here it’s named my-postgres for instance, and we mount a volume (e.g /tmp/my-pgdata) to our container, so that the database files are easier to access for other tools or applications on our host system. And remember to forward the default postgreSQL port and use -d
to put it to background. Next, we install postgreSQL command line client if you haven’t done that yet.
1 | sudo apt-get install postgresql-client |
Then, we connect to postgreSQL, either command below should work, postgres
is the default database and user name
1 | psql postgresql://postgres:my-password@127.0.0.1:5432/postgres |