This repository contains the source code for our official DomainMOD Docker container on Docker Hub:
https://hub.docker.com/r/domainmod/domainmod
Each image is built from the DomainMOD release it's tagged with: the build clones DomainMOD from GitHub at that release tag, so the application code isn't kept in this repository.
docker-compose.yml runs DomainMOD with a MariaDB database. Download it and .env.example into a new folder, then:
- Copy
.env.exampleto.envand setDOMAINMOD_PASSWORDandMARIADB_ROOT_PASSWORDin it. Use letters and numbers only, such as the output ofopenssl rand -hex 24. - Keep
.envprivate (chmod 600 .env). The passwords live there, not in the Compose file. - Run
docker compose up --wait, which returns once both containers pass their healthchecks, then openhttp://your-server:8080(or the port you set asDOMAINMOD_PORT). If it reports an error instead,docker compose psanddocker compose logsshow what went wrong.
The first time you open it, the installer asks you to choose the administrator account's username and password. Run it straight away, since until then anyone who can reach the port can set it up.
The MariaDB image has no 32-bit ARM (armv7) build, so on a 32-bit ARM system, use a MariaDB or MySQL image that has one, and change the db service's settings and healthcheck to match that image.
All of DomainMOD's data (your domains, settings, and users) is in the MariaDB database, so the database volume (db in the Compose file, mounted at /var/lib/mysql) is the one to keep and back up. The app volume (app, mounted at /var/www/html) holds DomainMOD's files, the config file the container writes on every start, and a few caches, so it can be recreated, though not while a restore is still finishing, since its progress is kept in the temp folder. Run docker compose down (without -v), remove only that volume (docker volume ls shows its full name), then run docker compose up --wait. Don't use docker compose down -v for this, since it also removes the database volume. DomainMOD's own backup (Administration -> Backup & Restore) also saves everything in the database.
Keep a copy of .env too: the database passwords and the MFA key aren't in the database or its backups. MariaDB only reads its passwords from .env the first time it starts, so to change one later, change it in MariaDB first, then in .env, then run docker compose up --wait to create the containers again with the new value.
The image's healthcheck asks the container's web server for /manifest.php every 30 seconds. It's a small page that runs PHP but needs no database and no sign-in, so the container shows as healthy once DomainMOD is being served, and a database outage doesn't mark it unhealthy. The page is in DomainMOD 4.26.0 and later. The Compose file has the same check, so it also covers the 4.26.0 image, which was built before the healthcheck was added. In the Compose file, the app waits for the database's own healthcheck before it starts.
The image sets DOMAINMOD_INSTALL_TYPE=docker, so DomainMOD's Upgrade page (Administration -> Upgrade, in 4.27.0 and later) knows it's running in this image and shows the Docker steps: pull the new image, then create the container again from it.
The container runs DomainMOD's Task Scheduler for you: cron inside the container runs cron.php every 10 minutes, so there's no cron job to set up on the host. It runs from the command line, so it works whether or not you've given cron.php a key in config.inc.php.
As of the 4.27.0 image, Apache runs as the image's domainmod user instead of www-data. That's the same user the Task Scheduler's cron job runs as, so both can write to DomainMOD's temp folder. If you mount a file for DomainMOD to read from outside /var/www/html, such as a CA certificate for an encrypted database connection, make sure the domainmod user can read it.
PUID and PGID set the user and group IDs of that domainmod user, and default to 1000 and 1000. Each time the container starts, it gives domainmod these IDs and makes it the owner of everything in /var/www/html. With a named volume, such as the Compose file's app volume, the defaults are fine. If you mount a folder from the host at /var/www/html instead, start with an empty folder (a new container copies DomainMOD into it), and set them to the IDs of the host user who should own the files (id your-username shows them). Pick IDs that no other user or group inside the container already has, apart from group 100. On Unraid, the template uses 99 and 100, Unraid's usual nobody user and users group.
DomainMOD 4.24.0 and later can encrypt the connection to the database and check the server's certificate. Set these environment variables to add the matching settings to config.inc.php (with the Compose file, add them to the app's environment section):
DOMAINMOD_DB_SSL_MODE:auto(the default when it's not set),verify, oroffDOMAINMOD_DB_SSL_CA: forverify, the path inside the container to the CA certificate that signed the database server's certificate (mount it into the container); the system's trusted CAs are used when it's not set
See the User Guide for details: https://domainmod.org/docs/userguide/database-encryption/
DomainMOD 4.27.0 and later can encrypt each user's MFA secret, so a copy of the database (such as a backup) doesn't give away the second step. We recommend setting DOMAINMOD_SECRET_KEY to a long random value when you first create the container, before anyone turns on MFA. To make one, run openssl rand -hex 32 on the host. When the variable is set, the container adds the matching setting to config.inc.php. Secrets saved before the key was set are encrypted the next time each user signs in with a code from their authenticator app, so backups taken before then still include them.
Keep the key safe with your other container settings, such as your Compose .env file or a password manager: it isn't in DomainMOD's backups. Use the same value whenever you create the container again or restore a backup on a new server. If the key is lost or changed, users with MFA on need a recovery code or an administrator's reset to sign in.
This repository also holds the templates that self-hosting app stores use to list DomainMOD, in the templates folder:
- Unraid Community Applications:
templates/unraid/domainmod.xml, with the repository's profile inca_profile.xml. It runs thelatestimage on its own, so install a MariaDB container from Community Apps first and enter its database details in the template.
Copyright (c) 2021-2026 Greg Chetcuti greg@chetcuti.com
Released under the GNU General Public License v3.0. See LICENSE.