---
title: Databases
url: 'https://niklas-stephan.de/en/wiki/software/datenbanken'
markdown: 'https://niklas-stephan.de/en/wiki/software/datenbanken.md'
lang: en
date: '2026-03-24'
description: 'Databases How-to reviewed 2026-11-28; tone-only edit, steps unchanged since the page date. Operating database systems is today as simple as never before – thanks to operating system containers such as Docker. Where configuring an Oracle database once took days of painstaking work, today such databa…'
---

#  Databases 

*How-to reviewed 2026-11-28; tone-only edit, steps unchanged since the page date.*

Operating database systems is today as simple as never before – thanks to operating system containers such as Docker.

Where configuring an Oracle database once took days of painstaking work, today such databases come up as a container with a few standard configuration options.

## Relational databases

The "classics" of databases.

For operation we need, besides the container as such, a volume for the persistent storage, environment variables, and a few configuration options.

Careful with the choice of the user under which the database container should run, since the permissions on the persistent volume carry through.

### MariaDB

MariaDB is an open-source project that originated as a fork of MySQL and has largely displaced that one.

#### Configuration

Example here.

compose.yml:

```yaml
<span class="hljs-attr">mariadb:</span>
  <span class="hljs-attr">container_name:</span> <span class="hljs-string">mariadb</span>
  <span class="hljs-attr">image:</span> <span class="hljs-string">mariadb:10.11</span>
  <span class="hljs-attr">user:</span> <span class="hljs-string">"1000:1000"</span>
  <span class="hljs-attr">restart:</span> <span class="hljs-string">unless-stopped</span>
  <span class="hljs-attr">command:</span> <span class="hljs-string">--transaction-isolation=READ-COMMITTED</span> <span class="hljs-string">--log-bin=binlog</span> <span class="hljs-string">--binlog-format=ROW</span> <span class="hljs-string">--log_bin_trust_function_creators=true</span>
  <span class="hljs-attr">volumes:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-string">./db:/var/lib/mysql</span>
  <span class="hljs-attr">env_file:</span> <span class="hljs-string">.env</span>
  <span class="hljs-attr">networks:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-string">default</span>
```

.env:

```ini
<span class="hljs-attr">MARIADB_ROOT_PASSWORD</span>=
<span class="hljs-attr">MARIADB_DATABASE</span>=
<span class="hljs-attr">MARIADB_USER</span>=
<span class="hljs-attr">MARIADB_PASSWORD</span>=
<span class="hljs-attr">TZ</span>=Europe/Berlin
<span class="hljs-attr">PUID</span>=<span class="hljs-number">1000</span>
<span class="hljs-attr">PGID</span>=<span class="hljs-number">1000</span>
```

#### Operation

Back up the database (backup or dump):

```bash
docker <span class="hljs-built_in">exec</span> DBCONTAINERNAME sh -c <span class="hljs-string">'exec mysqldump -u"root" -p"ROOTPASSWORD" "DBNAME"'</span> > dump.sql
```

Restore the database from the dump:

```bash
cat dump.sql | docker <span class="hljs-built_in">exec</span> -i DBCONTAINERNAME sh -c <span class="hljs-string">'exec mysql -u"root" -p"ROOTPASSWORD" "DBNAME"'</span>
```

### PostgreSQL

PSQL is the most beloved relational database in the open-source community and in modern software projects usually the standard.

compose.yml:

```yaml
<span class="hljs-attr">services:</span>
  <span class="hljs-attr">psqldb:</span>
    <span class="hljs-attr">container_name:</span> <span class="hljs-string">psqldb</span>
    <span class="hljs-attr">image:</span> <span class="hljs-string">postgres:15-alpine</span>
    <span class="hljs-attr">user:</span> <span class="hljs-string">"1000:1000"</span>
    <span class="hljs-attr">environment:</span>
      <span class="hljs-attr">POSTGRES_DB:</span> <span class="hljs-string">${POSTGRES_DB}</span>
      <span class="hljs-attr">POSTGRES_USER:</span> <span class="hljs-string">${POSTGRES_USER}</span>
      <span class="hljs-attr">POSTGRES_PASSWORD:</span> <span class="hljs-string">${POSTGRES_PASSWORD}</span>
    <span class="hljs-attr">restart:</span> <span class="hljs-string">unless-stopped</span>
    <span class="hljs-attr">volumes:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">./db:/var/lib/postgresql/data</span>
    <span class="hljs-attr">networks:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">default</span>
```

.env:

```bash
POSTGRES_DB=
POSTGRES_PASSWORD=
POSTGRES_USER=
PUID=1000
PGID=1000
TZ=Europe/Berlin
```

 databaseoverview

---

## Navigation

- Parent: [Software](https://niklas-stephan.de/en/wiki/software.md)
- Previous: [BOINC](https://niklas-stephan.de/en/wiki/software/boinc.md)
- Next: [Distrobox](https://niklas-stephan.de/en/wiki/software/distrobox.md)
