Each local Divio Cloud project creates a Docker container for its database.
Your local database and its container
The container name end in
_db_1 . If your project is named My Django Project, the container for its database will typically be
However, you can check using
docker ps , which will list the containers. The right-most column will give you the container names.
Running commands in the container
To run commands inside the container, use
In the container, the details you will need are:
- Postgres user:
- Postgres database:
No password is required.
Thus the general form of commands will be:
docker exec <container name> <command> -U postgres db <operation>
Get the help output from
docker exec mydjangoproject_db_1 psql -U postgres db --help
docker exec mydjangoproject_db_1 psql -U postgres --list
Dump and restore
Dump a database to a file named
docker exec mydjangoproject_db_1 pg_dump -U postgres db > dumped_data
To restore a database, apply the SQL commands from a database dump by piping them to through the
cat dumpdata | docker exec -i tour20170516_db_1 psql -U postgres db
Other Postgres-related commands, such as
dropbd , are also available, though it's beyond the scope of this article to provide details of their usage.