MySQL — the world's most popular open-source relational database (Oracle's official build). Deployed as a host-networked Nomad service with a persistent Docker volume. Use it when an app specifically needs Oracle MySQL; otherwise the mariadb pack is a drop-in.
Needs nomad-pack on PATH. The script only adds the nomploy registry and runs this pack.
Source ↗ Project ↗ ★ 12.4k ⚑ Report an issue
Save as values.hcl, edit, then run:
# The name of the Nomad job.
job_name = "mysql"
# The Nomad namespace to deploy into.
namespace = "default"
# The datacenters to deploy to.
datacenters = ["*"]
# The MySQL container image. Pin a tag in production.
image = "mysql:8"
# Host port MySQL listens on.
port = 3306
# Initial database created on first start (MYSQL_DATABASE).
database = "app"
# Application user created on first start (MYSQL_USER).
username = "app"
# Password for the application user (MYSQL_PASSWORD). CHANGE THIS.
password = "mysql"
# Password for the MySQL root user (MYSQL_ROOT_PASSWORD). CHANGE THIS.
root_password = "mysql"
# Named volume for the database (/var/lib/mysql).
data_volume = "mysql_data"
# Placement constraints. Pin to the node holding the volume. On a nomploy cluster: attribute = "$${meta.nomploy_control_plane}", operator = "=", value = "true".
constraints = []
# The task resources.
resources = {
cpu = 500
memory = 512
}
| Name | Type | Default | Description |
|---|---|---|---|
| job_name | string | "mysql" | The name of the Nomad job. |
| namespace | string | "default" | The Nomad namespace to deploy into. |
| datacenters | list | ["*"] | The datacenters to deploy to. |
| image | string | "mysql:8" | The MySQL container image. Pin a tag in production. |
| port | number | 3306 | Host port MySQL listens on. |
| database | string | "app" | Initial database created on first start (MYSQL_DATABASE). |
| username | string | "app" | Application user created on first start (MYSQL_USER). |
| password key | string | "mysql" | Password for the application user (MYSQL_PASSWORD). CHANGE THIS. |
| root_password key | string | "mysql" | Password for the MySQL root user (MYSQL_ROOT_PASSWORD). CHANGE THIS. |
| data_volume | string | "mysql_data" | Named volume for the database (/var/lib/mysql). |
| constraints | list | [] | Placement constraints. Pin to the node holding the volume. On a nomploy cluster: attribute = "$${meta.nomploy_control_plane}", operator = "=", value = "true". |
| resources | object | {
cpu = 500
memory = 512
} | The task resources. |
No variables match.
This pack stores data in one Docker named volume:
mysql_data
⚠ This pack bundles a database. A cold copy of the volume can be inconsistent — for a reliable backup, dump the DB (pg_dump / mysqldump) or stop the job while backing up.
restic
# Run on the node hosting this pack. Point restic at your repo first: # export RESTIC_REPOSITORY="s3:https://<account>.r2.cloudflarestorage.com/<bucket>" # export RESTIC_PASSWORD="<repo-password>" # export AWS_ACCESS_KEY_ID=<key> AWS_SECRET_ACCESS_KEY=<secret> restic backup \ /var/lib/docker/volumes/mysql_data/_data
rclone (sync to S3/R2)
rclone sync /var/lib/docker/volumes/mysql_data/_data backup:<bucket>/mysql_data
Paths assume the default Docker volume location (/var/lib/docker/volumes). Restore by stopping the job, restoring files into the same volume, and re-running the pack.
MySQL — the world's most popular open-source relational database (Oracle's official build). Use this when an app specifically requires Oracle MySQL; otherwise the mariadb pack is a lighter drop-in.
Host-networked Nomad service with a persistent Docker volume.
nomad-pack registry add nomploy https://github.com/Nomploy/nomad-packs
nomad-pack run mysql --registry=nomploy
| Variable | Default | Description |
|---|---|---|
port |
3306 |
Listen port. |
database / username / password |
app / app / mysql |
Initial DB + app user. Change the password. |
root_password |
mysql |
Root password. Change it. |
data_volume |
mysql_data |
/var/lib/mysql. |
image |
mysql:8 |
Container image. Pin a tag in production. |
resources |
{ cpu = 500, memory = 512 } |
Task resources. |
Pin the job to the node holding the volume with constraints.