> ## Documentation Index
> Fetch the complete documentation index at: https://docs.levelrail.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Self-host 2FAuth with Docker

> A web app to manage your two-factor authentication accounts and generate one-time codes.

A web app to manage your two-factor authentication accounts and generate one-time codes.

This page describes the Levelrail template for 2FAuth (Security). It deploys the services below as one Docker Compose app on your own server. Project site: [https://docs.2fauth.app](https://docs.2fauth.app).

Recommended memory: about 128 MiB.

## Services, ports and volumes

| Service | Image | Container ports | Volumes |
| - | - | - | - |
| `2fauth` | `2fauth/2fauth:8.0.2` | 8000 | `twofauth_data -&#62; /2fauth` |

## Environment variables

| Service | Variable | Value |
| - | - | - |
| `2fauth` | `APP_KEY` | Generated at deploy |
| `2fauth` | `APP_URL` | Preset in the template |
| `2fauth` | `DB_CONNECTION` | Preset in the template |
| `2fauth` | `SITE_OWNER` | Preset in the template |

Passwords and keys marked as generated are created for you when the app is deployed and stored as secrets. Values are not shown here.

## Deploy 2FAuth with Levelrail

In the dashboard, open **Apps**, choose **New app**, then **Browse templates**, and select 2FAuth. Review the Compose body and deploy.

With the CLI:

```bash theme={"dark"}
levelrail-cli templates deploy 2fauth --name my-2fauth
```

See the [service template catalog](/templates-and-registry) for how templates work, and [Getting started](/getting-started) if you have not installed Levelrail yet.

## More Security templates

* [authentik](/self-host/authentik)
* [Cap](/self-host/cap-captcha)
* [Cryptgeon](/self-host/cryptgeon)
* [Infisical](/self-host/infisical)
* [Keycloak](/self-host/keycloak)

All templates are listed in the [self-host gallery](/self-host).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.