Running DomainMOD With Docker
Get it running in three steps with our official Docker image and Docker Compose
What you need
All you need is a server or computer with Docker, Docker Compose, and curl. With our official image, you get:
- Easy updates with two Docker Compose commands
- The Task Scheduler, with no cron job to set up
- PHP, a web server, and every extension it needs
- Every locale for the translations
- A settings file from your environment
- Folder permissions set up for you, including the temp folder
The Compose file runs DomainMOD with a MariaDB database. MariaDB's 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.
Install in three steps
Run these on your server, one step at a time. The first step makes a new folder named domainmod and moves into it, so the other two run there.
-
mkdir domainmod && cd domainmod && curl -fsSLO https://raw.githubusercontent.com/domainmod/docker-source/master/docker-compose.yml && curl -fsSLO https://raw.githubusercontent.com/domainmod/docker-source/master/.env.example && cp .env.example .env && chmod 600 .env -
Open
.envand give these two settings a password each, using letters and numbers only:DOMAINMOD_PASSWORDMARIADB_ROOT_PASSWORD
Tip:
openssl rand -hex 24makes a strong one -
docker compose pull docker compose up --wait
First run
docker compose up --wait finishes once both containers are running and healthy. Then open http://your-server:8080 in your browser, with your server's address in place of your-server (and the port you chose, if you set DOMAINMOD_PORT).
Run the installer before you do anything else. Until it's finished, anyone who can reach that port could set up DomainMOD and choose the administrator's username and password.
If docker compose up --wait reports an error instead, docker compose ps and docker compose logs show what went wrong.
Keeping your data
All of DomainMOD's data, including your domains, settings, and users, is in the MariaDB database, so the database volume (db in the Compose file) is the one to keep and back up. You can also back up the database from inside DomainMOD, in Administration -> Backup & Restore.
Keep a copy of your .env file too. It holds the database passwords, and the MFA key if you've set one, which 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, and then run docker compose up --wait to create the containers again with the new value.
docker compose down -v. The -v removes the volumes as well, including the database volume with all your data.
Upgrading
Back up your database first, in Administration -> Backup & Restore. The Compose file uses the latest image, so if you've changed it to a version tag, change that tag to the new version, or back to latest.
Then, in the folder with your Compose file, pull the new image and create the DomainMOD container again from it. These commands update only the app service, so the database keeps running as it is:
docker compose pull app && docker compose up -d --no-deps app
Restarting the same container doesn't upgrade it, since it has to be created again from the new image.
If you run the image another way, such as with docker run, pull the new image with docker pull domainmod/domainmod:latest, then stop and remove the container and create it again with the same settings. If your container uses a version tag instead of latest, use the new version's tag for both.
The 4 and 4.27 tags stay on 4.27.0, so if your Compose file or docker run command names either of them, change it to 5.0.0 for this release, or to 5, 5.0, or latest, which also pick up later releases.
Then sign in. If DomainMOD asks you to upgrade the database, click Upgrade Database. In DomainMOD 4.27.0 and later, Administration -> Upgrade shows the Docker upgrade steps too.
Settings
The Compose file reads its settings from .env. As of v5.0.0, single sign-on needs none of them, since it's set up on Administration -> Single Sign-On. Apart from the two passwords, every setting is optional, so you only need to change what you want to:
DOMAINMOD_PORT- The port DomainMOD answers on, on the host (8080 unless you change it).
TZ- The containers' time zone, as a name from the tz database, such as
Europe/London(Etc/UTCunless you change it). PUIDandPGID- The user and group IDs that own DomainMOD's files and run its Task Scheduler (1000 unless you change them). The defaults suit the Compose file's own volume. If you mount a host folder at
/var/www/htmlinstead, start with an empty folder, and use the IDs of the host user who should own the files, whichid your-usernameshows. Pick IDs that no other user or group in the container already has (group 100 is fine). DOMAINMOD_SECRET_KEY- Recommended. A long random value that encrypts each user's MFA secret and every saved credential. We recommend setting it before anyone turns on MFA or saves a credential, and you can make one with
openssl rand -hex 32. Keep it somewhere safe, since it isn't in DomainMOD's backups, and use the same value whenever you create the container again or restore a backup on a new server. If you're reusing a key that has a$in it, put the key in single quotes. DOMAINMOD_PREVIOUS_SECRET_KEY- Only while changing the key: the old key, so values encrypted with it can still be read until they're encrypted again with the new one (see Changing the Key in the User Guide). Remove it once Administration -> MFA Key says it can come out. If your
docker-compose.ymlis from before v5.0.0, addDOMAINMOD_PREVIOUS_SECRET_KEY: ${DOMAINMOD_PREVIOUS_SECRET_KEY:-}under itsenvironment:first, or the container won't get the old key. DOMAINMOD_WEB_ROOT- Set this only if DomainMOD runs in a subfolder behind a reverse proxy, such as
/domainmod. DOMAINMOD_DATABASEandDOMAINMOD_USER- The database's name and user (both
domainmodunless you change them). The database container creates both the first time it starts, so set them before then. Use letters, numbers, and underscores only, and don't userootas the user.
Encrypted database connections
DomainMOD can encrypt the connection to its database and check the database server's certificate. To set it up, add these to the app service's environment section in the Compose file:
DOMAINMOD_DB_SSL_MODEauto(the default when it isn't set),verify, oroff.DOMAINMOD_DB_SSL_CA- For
verify, the path inside the container to the CA certificate that signed the database server's certificate. Mount that file into the container where itsdomainmoduser can read it. When it isn't set, the system's trusted CAs are used.
See Encrypted Database Connections in the User Guide.
Unraid
An Unraid template is in the templates folder of the image's source on GitHub. It runs the DomainMOD image on its own, so set up a MariaDB container first, then enter that database's details in the template.