Skip to main content

User Guide · for DomainMOD 5.0.0

Running With Docker

On This Page

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.

  1. Get the files

    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
    
  2. Set two passwords

    Open .env and give these two settings a password each, using letters and numbers only:

    • DOMAINMOD_PASSWORD
    • MARIADB_ROOT_PASSWORD

    Tip

    openssl rand -hex 24 makes a strong one

    Then set the MFA key, which encrypts each user's MFA secret and every saved credential: run openssl rand -hex 32, and put its output after DOMAINMOD_SECRET_KEY= on that line in .env. Set it when you install. To change it later, follow Changing the Key, with DOMAINMOD_PREVIOUS_SECRET_KEY for the old one.

  3. Start it

    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.

Once you've signed in, Administration -> MFA Key shows the MFA key as "Set (key ID …)". Note that ID. It should stay the same after every update or redeployment, which shows the app is using the key in .env. Run Docker Compose from a clean shell: a DOMAINMOD_SECRET_KEY exported in your shell overrides .env for that one deployment, and a later one would switch keys.

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 (see 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.

Warning

Never run 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. 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, 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.

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 (see 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/UTC unless you change it).

PUID and PGID
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/html instead, start with an empty folder, and use the IDs of the host user who should own the files, which id your-username shows. 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, which you can make 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. docker compose config and docker inspect show it, and so does the environment of any command run with docker compose exec or docker exec, so don't share their output as it is. If you're reusing a key that has a $ in it, put the key in single quotes in .env, but not in a file you pass to docker run --env-file, which keeps quotes as part of the value.

An existing install that has never had a key (Administration -> MFA Key shows "Not set") can set one at any time: set it in .env (or your container's settings), create the container again, and each user's secret is encrypted the next time they enter a correct code. If that page shows "Not set, but … encrypted" instead, such as after a redeployment that left the key out or a restore onto a container without it, put the original key back in .env and create the container again before anyone signs in, since a new key won't open those secrets. No other administrator can reset the MFA of the account with the username admin, so if the original key encrypted its secret and can't be put back, its recovery codes are its only way back in. If you don't use the Compose file, set the key in your container's settings, and with docker run, pass it with --env-file rather than -e, which would put the key in your shell's history.

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). Remove it once Administration -> MFA Key says it can come out. If your docker-compose.yml is from before v5.0.0, add DOMAINMOD_PREVIOUS_SECRET_KEY: ${DOMAINMOD_PREVIOUS_SECRET_KEY:-} under its environment: first, or the container won't get the old key. Like DOMAINMOD_SECRET_KEY, it's kept out of the Task Scheduler's environment file and out of the web server's and the Task Scheduler's processes once the configuration is written, but Docker itself still keeps it in the container's settings.

DOMAINMOD_WEB_ROOT
Set this only if DomainMOD runs in a subfolder behind a reverse proxy, such as /domainmod. Behind a proxy that handles HTTPS, the proxy has to set X-Forwarded-Proto itself, replacing any value it's sent (see Security and MFA).

DOMAINMOD_DATABASE and DOMAINMOD_USER
The database's name and user (both domainmod unless 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 use root as 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_MODE
auto (the default when it isn't set), verify, or off.

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 its domainmod user can read it. When it isn't set, the system's trusted CAs are used.

See Encrypted Database Connections for details.

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.

More Detail

Edit this page on GitHub