Skip to content

docker-mailserver

The docker-mailserver connector reads an installation in two ways. Mail and Sieve scripts come over IMAP and ManageSieve, signed in through a Dovecot master user. Accounts, password hashes, quotas, aliases and DKIM keys come from the config volume on the Docker host, read through host access. Only the FILE account provisioner is supported; an installation that keeps its accounts in LDAP is migrated as an other IMAP server, with its accounts listed in a CSV file.

docker-mailserver runs Dovecot and Postfix, so it takes the same cutover strategies as a Dovecot and Postfix server: a zero-downtime migration with the Stalwart proxy in front of the container, which the operator controls, or a one-shot migration per domain. Detection does not recognise docker-mailserver, only the Dovecot inside it, so the system is chosen by hand on the Source: detect step.

Mail is copied over IMAP with the folder tree, and Sieve scripts over ManageSieve when ManageSieve is enabled and its URL is set. Vacation replies and filters exist only as Sieve scripts. The installation has no calendars, contacts, files or sender identities for Vandelay to read.

Accounts come from postfix-accounts.cf, with their password hashes, and quotas from dovecot-quotas.cf. A hash is carried when Stalwart supports its scheme, as described in Password hashes. An account marked nologin is created disabled on Stalwart. Aliases, mailing lists, catch-all addresses and domain aliases come from postfix-virtual.cf, read as Postfix would read it, with the first matching line winning.

DKIM keys are carried, in a server-scope project, from OpenDKIM (opendkim/KeyTable and the key files under opendkim/keys) or from Rspamd (the domains, selectors and key files named in rspamd/override.d/dkim_signing.conf, with its selector map). Every key file must lie inside the config volume.

  1. Create the master user in the container, then restart the container:

    Terminal window
    docker exec -it mailserver setup dovecot-master add vandelay
    docker restart mailserver

    Vandelay checks that dovecot-masters.cf lists the master user named in the plan.

  2. To carry Sieve filters, set ENABLE_MANAGESIEVE=1 in mailserver.env, publish port 4190, and restart the container. Without ManageSieve, no Sieve script is migrated.

  3. Give Vandelay read access to the config volume on the Docker host, locally or over SSH, as described in Host access. docker-mailserver writes these files as root and keeps the DKIM keys readable by their owner only, so the host access user is usually root.

  4. Make sure that no user other than the owner can write the config directory, its parents or the files Vandelay reads. These files decide which accounts and password hashes are created on Stalwart, so a group- or world-writable directory or file is refused; chmod go-w removes the write bit, or the volume is copied to a directory only its owner can write. A directory inside a shared directory such as /tmp must be owned by root.

  5. Keep every DKIM key inside the config volume: OpenDKIM keys under opendkim/keys, with the KeyTable pointing at /etc/opendkim/keys, and Rspamd keys as files that dkim_signing.conf names under /tmp/docker-mailserver.

The same steps are printed by vandelay migrate guide docker-mailserver and shown on the Source: access step of the web UI and the TUI. Vandelay writes nothing on the source.

The settings that a Dovecot and Postfix source needs behind the Stalwart proxy are described in Proxy mode settings and apply here: Dovecot and Postfix trust the proxy’s address, and Postfix accepts mail relayed from Stalwart without checking it again. On docker-mailserver, Dovecot settings go into dovecot.cf and Postfix main.cf settings into postfix-main.cf, both in the config volume, and take effect when the container restarts. When Rspamd is enabled, Stalwart’s address must also be exempted from its checks.

Vandelay reads the container directly, at its published IMAP and ManageSieve ports, never through the proxy.

The endpoints are “IMAP URL” (source.imap, --imap-url), the IMAP or IMAPS address of the container, and “ManageSieve URL” (source.sieve, --sieve-url). The master user is required: “Master user” (source.master.name, --master-user) and “Master, admin or service account password” (source.master.password, --master-password), a secret reference. The separator * is the default “Master login format”, as described in Master user.

Host access is required too: “Server file access” (source.host.kind, --host-access) reaches the Docker host, and “docker-mailserver config directory” (source.config, --dms-config) is the host directory mounted at /tmp/docker-mailserver in the container. In the docker-mailserver compose example this is docker-data/dms/config next to compose.yaml, and docker inspect mailserver shows it under Mounts. The container path is not the right value, because /tmp on the host is a different directory. The path must be absolute.

The following excerpt reads the installation over SSH, with the master password in an environment variable of the runner:

[source]
system = "docker-mailserver"
imap = "imaps://mail.example.org"
sieve = "sieve://mail.example.org:4190"
config = "/srv/mailserver/docker-data/dms/config"
cleartext = "forbid"
[source.master]
name = "vandelay"
password = "env:DMS_MASTER_PASSWORD"
form = "*"
[source.host]
kind = "ssh"
destination = "[email protected]"

The following command sets the same source:

Terminal window
vandelay migrate source \
--system=docker-mailserver \
--imap-url=imaps://mail.example.org \
--sieve-url=sieve://mail.example.org:4190 \
--master-user=vandelay \
--master-password=env:DMS_MASTER_PASSWORD \
--host-access=ssh \
--dms-config=/srv/mailserver/docker-data/dms/config

Pre-flight lists the following as losses, and “Verify and report” lists them per account:

  • Per-user Sieve files. docker-mailserver installs <address>.dovecot.sieve as the user’s active script, which ManageSieve may not list. The loss says it migrates only if ManageSieve lists it as a script, so check the user's filter on the target.
  • Global Sieve scripts and extprograms. The scripts run before and after every user’s filter, and the Sieve extprograms filter and pipe scripts, are not migrated.
  • Polling and relaying. fetchmail and getmail polling of external mailboxes is not migrated, so mail from them stops arriving after the switch; nor are the outbound relay map and the relay host credentials.
  • Overrides and restrictions. The Dovecot and Postfix override files, regular expression aliases in postfix-regexp.cf, local aliases in postfix-aliases.cf, and the send and receive restrictions are each reported with their file and line.
  • Forwarding. A forward in postfix-virtual.cf is reported as Postfix virtual_alias_maps forwarding is not migrated; recreate it as a redirect rule: <targets>.
  • Disabled mailboxes. docker-mailserver’s Dovecot refuses a nologin account even to the master user, so a run copies none of its mail and records the mailbox was disabled on the source when vandelay read it, so that attempt copied no mail and no Sieve scripts from it. What an earlier run copied stays. To copy its mail, remove nologin, restart the container and run again. A mailbox disabled after discovery is reported by pre-flight; discovery is then run again.
  • DKIM keys that cannot be carried. A key that the volume does not hold, a domain that both OpenDKIM and Rspamd sign, Rspamd keys kept in Redis or Vault or behind a path_map, UCL macros such as .include, and dkim_signing options set in rspamd/custom-commands.conf are reported instead of read, each with the fix. Without a carried key, a server-scope project has Stalwart generate a new one, whose DNS record must be published; an account-scope project carries no DKIM keys at all. A subdomain that Rspamd signs with its parent’s key (use_esld) gets a new key of its own in a server-scope project, and a selector that is not a DNS label, such as one with an underscore, is not carried.

Quotas from dovecot-quotas.cf are set on Stalwart even when the installation does not enforce them (ENABLE_QUOTAS); they are removed on Stalwart afterwards when they should not apply.

not found; only the FILE account provisioner is supported (for LDAP, list the accounts in a CSV file and use the imap source) means that postfix-accounts.cf is missing from the configured directory: either the path is wrong or the installation uses LDAP. is not an absolute path; set config to the host directory mounted at /tmp/docker-mailserver names the container path or a relative one. can be written by users other than its owner (group or world writable), so its accounts, hashes and keys cannot be trusted is fixed with chmod go-w on the named file or directory, or by copying the volume to a directory only its owner can write.

the master user "vandelay" is not listed; create it with `setup dovecot-master add` and restart the container means that dovecot-masters.cf does not list the master user named in the plan, or the container has not been restarted since it was added.