docker-exim4

A minimal, full-featured Exim 4 image built on scratch from Debian Unstable's exim4-daemon-heavy, rebuilt daily. Docker Hub: https://hub.docker.com/r/grepular/exim4

Active Pure Nim score 65/100 · last commit 2026-10-04 · 1 stars · tests present · no docs generated

Summary

Latest Version Unknown
License Unknown
CI Status Failing
Stars 1
Forks 0
Open Issues 0
Last Commit 2026-10-04
Downloads 0
Last Indexed 2026-11-23 09:07

Installation

nimble install docker-exim4
choosenim install docker-exim4
git clone https://gitlab.com/grepular/docker-exim4

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
docker-exim4 ✓ ✓ ✓ - - - - - - -

README

Exim4-Docker

Overview

This repo was built to provide an automatically maintained, full featured Exim 4 Docker image on Docker Hub at grepular/exim4, with as little as possible inside the container to reduce the impact of any vulnerabilities in Exim. The image is built using a multi-stage build, starting with a Debian Unstable image with the exim4-daemon-heavy package, and copying the minimal amount of stuff into a scratch image. Debian Unstable is used rather than Testing because security fixes are uploaded to Unstable directly and can take weeks to migrate to Testing:

  1. The exim4 binary from the exim4-daemon-heavy Debian package stored at /usr/sbin/exim4.real
  2. The shared libs that the exim4 binary is linked against
  3. The mailq symlink to /usr/bin/mailq
  4. Timezones from the Debian unstable tzdata package
  5. CA certificates
  6. /etc/services, /etc/aliases, and /etc/email-addresses
  7. A custom entrypoint wrapper program at /usr/sbin/exim4

The entrypoint wrapper program does a number of things at startup and then overwrites it's self by moving the real binary from /usr/sbin/exim4.real. It does the following:

  1. Escalates privileges to root thanks to the setuid bit
  2. Creates a system Debian-exim user and group with the uid and gid that you started the container with
  3. Sets the system timezone from the TZ environment variable (defaulting to UTC if not supplied)
  4. Overwrites it's own filesystem path with the real exim binary
  5. If no spool dir exists at /var/spool/exim4 it creates one, and chowns it to allow the starting user to write to it
  6. Drops privileges back to the original user
  7. Replaces it's running process with the real exim binary

This allows you to specify the timezone and the uid and gid that you wish Exim to use, at runtime. An example execution using Europe/London timezone and arbitrary uid:gid of 65534:65534 follows. If you try to run this image as root it will fail:

docker run --rm \
    --cap-drop=all \
    --cap-add=CAP_SETGID \
    --cap-add=CAP_CHOWN \
    --hostname hostname.for.banner \
    -u 65534:65534 \
    -e TZ=Europe/London \
    -p 127.0.0.1:25:25 \
    -v "/opt/exim4/etc/exim4.conf:/etc/exim4/exim4.conf:ro" \
grepular/exim4:latest

Capabilities

In the above example, I dropped all capabilities and re-added CAP_SETGID and CAP_CHOWN. CAP_SETGID is required as Exim uses setgroups to drop suplimentary groups. CAP_CHOWN is only required if you do not mount a spool dir of your own at /var/spool/exim4. If this dir is missing when the container starts, it creates it and chowns it to the uid:gid that you run the container as.

Configuration

The image comes without any configuration. You must mount your own at /etc/exim4/exim4.conf at runtime, or build an image based on this one with your exim config as an addition. The config file must be owned by root and have no write perms for any other users. Mount read-only like in my example as well, because why not?

Logs

Typically with a docker container you want logs to go to stdout/stderr. By default this image works that way. It does so by symlinking /var/log/exim4/mainlog to /dev/stdout and /var/log/exim4/{rejectlog,paniclog} to /dev/stderr. You can of course override this, for example by bind mounting to /var/log/exim4. If you do that, you can rotate logs by moving them and sending a HUP to the exim4 process. There is no kill binary inside the container so you will have to do it from the host.

Default command

The default command is /usr/sbin/exim4 -bdf -q5m. The -bdf option keeps Exim attached to the terminal so that the docker container doesn't exit. The -q5m option starts at new queue runner every 5 minutes.

Image Build / Deployment / Tags

There is a gitlab workflow which runs automatically once a day. It will build a new docker image and then push it to docker hub if any of the content of any of the files inside the image has changed. I.e if the Exim binary or any of the shared libs, or CA certs etc are updated.

It will push a tag like this for example:

  • 4.98.2-1_170e0ed1d698

Where 4.98.2 is the version of Exim, 1 is the Debian revision of the Exim package, and 170e0ed1d698 is the hash of all of the files within the image. If you want to pin to an exact immutable image, then that is the sort of tag you should use. Debian binNMU versions like 4.99.4-2+b1 appear with an underscore instead of the + (e.g 4.99.4-2_b1), because Docker tags may not contain +.

When we push the above tag, we also push the following tags:

  • 4.98.2-1 - Follow a specific Debian Exim package
  • 4.98.2 - Follow a specific version of Exim
  • 4.98 - Follow the latest patch release for a specific version of Exim
  • latest - Follow the latest version of Exim 4

Once a newer Debian package exists for Exim, we will not continue providing updates to the earlier versions tags. I.e once 4.99.1-1 exists, we wouldn't go back and update 4.98.2-1 or 4.98.2 or 4.98 again. Not automatically at least.

Support/Appreciate my work