---
website: https://matrix.org/
obj: application
rev: 2024-01-19
---

# Matrix
Matrix is an open standard and communication protocol for real-time communication. It aims to make real-time communication work seamlessly between different service providers, in the way that standard [Simple Mail Transfer Protocol](../../internet/SMTP.md) [email](../../internet/eMail.md) currently does for store-and-forward [email](../../internet/eMail.md) service, by allowing users with accounts at one communications service provider to communicate with users of a different service provider via online chat, voice over IP, and videotelephony. It therefore serves a similar purpose to protocols like XMPP, but is not based on any existing communication protocol.

By default matrix is federated and every user is located at a home server (`@user:matrix.example.org`) and can communicate with other users or join rooms.

## Setup
To setup a matrix server using dendrite follow these steps. As prerequisites you need a valid [domain](../../internet/Domain.md) name.

### Generate a key
```shell
mkdir -p ./config
docker run --rm --entrypoint="/usr/bin/generate-keys" -v $(pwd)/config:/mnt matrixdotorg/dendrite-monolith:latest -private-key /mnt/matrix_key.pem
```

### Generate a config file
```shell
mkdir -p ./config
docker run --rm --entrypoint="/bin/sh" -v $(pwd)/config:/mnt matrixdotorg/dendrite-monolith:latest -c "/usr/bin/generate-config -dir /var/dendrite/ -db postgres://dendrite:itsasecret@postgres/dendrite?sslmode=disable -server YourDomainHere > /mnt/dendrite.yaml"
```

## Administration
**Create a new Account:**
To create a new account, use this command inside the dendrite container:
```sh
/bin/create-account -config /path/to/dendrite.yaml -username USERNAME [-admin]
```

### Docker-Compose
Start the docker compose service:
```yaml
version: "3.4"

services:
  postgres:
    hostname: postgres
    image: postgres:15-alpine
    restart: always
    volumes:
      - ./db:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: password
      POSTGRES_USER: dendrite
      POSTGRES_DATABASE: dendrite
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U dendrite"]
      interval: 5s
      timeout: 5s
      retries: 5

  dendrite:
    image: matrixdotorg/dendrite-monolith:latest
    ports:
      - 8448:8008
    volumes:
      - ./config:/etc/dendrite
      - ./data:/var/dendrite
    depends_on:
      postgres:
        condition: service_healthy
    restart: unless-stopped
```
