Self-host MySQL with Levelrail

The MySQL Community database server on the official image, with a persistent volume, generated root and user passwords, and an application database. It is not published on the host, so reach it from other services in this project at mysql:3306.

  • Authormysql
  • LicenceGPL-2.0-only
  • Memory768 MiB
  • Services1

How to self-host MySQL

  1. Pull the images

    One image is pulled on your server.

    Show images
    • mysql:8.4.13
  2. Create the app

    One service starts in a single Compose app, with 1 named volume mount for your data, on port 3306.

  3. Fill in the secrets

    2 secrets are generated and stored encrypted, 2 settings are preset, you do not have to fill in anything.

  4. Open it

    Without a domain the app gets an sslip.io address; add --domain SERVICE=HOST to use your own.

After the first start

  • Read the generated passwords from the app secrets, then connect with the application user or as root from a service in the same project.

MySQL requirements

Memory
About 768 MiB
Architectures
amd64 unknown, arm64 unknown
Ports
3306
Domain
Optional, an sslip.io address is used without one
Settings
none to fill in
License
GPL-2.0-only, copyleft license
  • Listed. It is in the catalog but not verified. Back up the data volume before changing an image tag.

Install Levelrail first

On a server with Levelrail running, run the command above, or open the dashboard: Apps, New app, Browse templates, then MySQL. New to Levelrail? Install it on a fresh VPS first.

docker pull ghcr.io/glincker/levelrail:latest

Then levelrail-cli login --device. See Getting started and the MySQL docs page.

Deploy MySQL your way

Every format below deploys the same pinned images. Pick the one that fits how you work.

Deploy MySQL from the CLI

Add --domain SERVICE=HOST to serve a service on your own domain, for example --domain mysql=app.example.com.

levelrail-cli templates install mysql --name my-mysql

Deploy MySQL with the API

Create a token in the dashboard first. Name, env and domains are the request fields.

curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  https://levelrail.example.com/api/v1/service-templates/mysql/install \
  -d '{
    "name": "my-mysql"
  }'

MySQL configuration

MySQL services

ServiceImagePortsVolumes
mysql mysql:8.4.13 3306 mysql_data -> /var/lib/mysql

MySQL environment variables

VariableServiceValue
MYSQL_DATABASE mysql Preset by the template
MYSQL_PASSWORD mysql Generated at deploy
MYSQL_ROOT_PASSWORD mysql Generated at deploy
MYSQL_USER mysql Preset by the template

Ports and volumes

Ports
3306
Volumes
1 named mount: mysql_data -> /var/lib/mysql

MySQL FAQ

How much memory does MySQL need?

The catalog lists about 768 MiB of memory for MySQL.

Does MySQL run on arm64?

For MySQL, arm64 support is not confirmed; amd64 is unknown.

What licence is MySQL under?

MySQL is licensed under GPL-2.0-only, which is copyleft, so changes you distribute must be shared under the same terms.

Does MySQL need configuration before it starts?

No. The template fills in its own defaults and generates secrets at deploy time.

Which database does MySQL bundle?

The template includes MySQL, running as part of the stack.

Which ports does MySQL use?

MySQL listens on port 3306 inside the stack.

Where does MySQL keep its data?

In a named volume: mysql_data mounted at /var/lib/mysql.

Can I deploy MySQL on Dokploy or Dokku?

The services and pinned images on this page can be run on any Docker host. The public Dokploy templates list we compared does not have an entry with the same id for MySQL, so on Dokploy you would use a Docker Compose application with the file from this page. Dokku deploys container images with its own commands, so the pinned image mysql:8.4.13 is what you deploy there.

levelrail-cli templates install mysql --name my-mysql