๐ฝDatabases
Databases kept in separate docker stack and network, because there might be other services uses databases. Currently there are 2 databases being used by Nextcloud
Postgresql
Redis
Deploy
Make surenetwork_databases
is created. Know more in Traefik section
$ git clone git@github.com:veerendra2/raspberrypi-homeserver.git
$ cd raspberrypi-homeserver/services/databases
$ docker stack deploy -c docker-stack.yml databases
Secrets
Databases passwords are stored docker secrets which are defined in the stack.
$ docker secret ls
ID NAME DRIVER CREATED UPDATED
iwf1jjhfc1wd2hzftp8f41247 databases_postgres_password 6 minutes ago 6 minutes ago
a6cm47sv3lzkj7936gqrblv1f databases_postgres_user 6 minutes ago 6 minutes ago
nf17rcx3nqdv34cpa6m89bws5 databases_redis_host_password 6 minutes ago 6 minutes ago
For example, you can use databases secrets in other stack like below
```
version: '3'
secrets:
db_user:
external: true
db_password:
external: true
services:
postgres_db:
image: postgres
secrets:
- db_user
- db_password
```
Create database
Default user trinity
and nextcloud
database create during startup. If required create databases manually for other services
# Find the postgres container
$ docker ps | grep postgres
$ docker exec -it --user postgres [CONTAINER_ID] /bin/sh
$ psql -U veerendra
Run below sql command to create database(If required, create user too)
CREATE USER suma WITH ENCRYPTED PASSWORD 'mypass';
CREATE DATABASE mydb;
GRANT ALL PRIVILEGES ON DATABASE mydb TO suma;
Last updated
Was this helpful?