Deploying & Running Axigen in Docker

Axigen Documentation

Updated: April 25, 2024

Introduction

To be able to run an Axigen-based mail service within a Docker container, all you need to do is download, deploy, and run the Axigen Docker Image.

In the following guide, we’ll explain the Axigen Docker image and how you can use it to create a new Axigen mail server instance.

Axigen Docker Image Structure

The image relies on a Ubuntu 20.04 image; on it, Axigen is installed and basic configuration is performed.

The disk structure is the following:

  • /axigen/bin — binaries and other files

  • /axigen/var — data and config files

The /axigen/var is configured as a Docker volume and must be preserved between container runs, to preserve the mail server data (configuration, mailbox data, etc.).

The following services are enabled and mapped as 'exposed' TCP ports in Docker:

  • SMTP (25 - non secure, 465 - TLS)

  • IMAP (143 - non secure, 993 - TLS)

  • POP3 (110 - non secure, 995 - TLS)

  • WEBMAIL (80 - non secure, 443 - TLS)

  • WEBADMIN (9000 - non secure, 9443 - TLS)

  • CLI (7000 - non secure)

Using the Axigen Image / Container

An important point is that the Axigen instance data is not stored in the container itself. The container holds just package files (binaries and so on), while the instance data is stored in the "/axigen/var" volume also referred to as the Axigen Data Volume. This is where the actual server configuration and the server (mailbox / users) data are located. A container may be deleted, upgraded (new container created from a newer image), stopped, started, and the server data will be preserved, as long as the Docker volume which is mapped upon container startup is preserved.

1. Creating a New Axigen Mail Server Instance

The Axigen data volume may be mapped, upon container creation, to the Docker volume or to a host filesystem path (bind mount). The latter approach is recommended, allowing the administrator to examine the Axigen data files (storage, logs, configuration) directly from the Docker host.

Running Axigen X5 Beta

If you want to run Axigen X5 Beta instead of X4, please append the 10.5-edge suffix:

The following options are used:

  • -d → detach from the container (since we want it to run in the background)

  • -t → allocate a pseudo-TTY to allow capturing Axigen stdout in the Docker logs

  • -v → map a volume in /axigen/var; <volume> may be a Docker volume or a local host path (bind mount). See the The Axigen Data Volume section below for more details.

  • -p → port mapping: map the ports exposed by the container (Axigen, in this case) to host ports. In the example above, ports 443 (WebMail), 9443 (WebAdmin), 993 (IMAPs) and 995 (POP3s), 25 (SMTP) and 465 (SMTPs) are mapped. The Axigen container also exposes other ports which may me mapped, if needed (see the Image structure section).

When the Axigen data volume (be it a Docker volume or a bind mount) is first used in the container, it will be initialized.
Upon creation, the container will also be started.

Check that the container is running:

The output should display a running container, along with the port mapping and other information:

At this point, if the WebAdmin port was mapped (-p 9443:9443), the Axigen WebAdmin interface should be accessible via the host IP: https://localhost:9443/

Note that by default the Axigen image uses a self-signed SSL certificate. This will cause your browser to issue a warning when you access the WebAdmin and WebMail. The default certificates can be replaced via WebAdmin.

1.1. Using Docker Compose

Docker Compose allows you to run multiple containers by managing networks and services. In instances where a network is not pre-defined, Docker Compose will automatically create a new network, attaching all associated services to it. In our example, we will explicitly configure a new bridge network named axi-network.

Please replace <volume> with your disk path that will hold Axigen persistent data.

2. Stopping and Starting the Container

Like any container, the Axigen container may be operated using either the container name (i.e. axigen in our example) or the <container_id>. The <container_id> is obtained from the output of the docker ps command. Axigen containers (including stopped ones) may be viewed with the docker ps -a -f ancestor=axigen/axigen[:<image_tag>] command.

A running Axigen container may be stopped by using the docker stop axigen command. When a container is stopped, its full state is preserved, only the Axigen process is stopped.

A stopped Axigen container may be started by using the docker start axigen command.

You can as well restart the container (also restarts the Axigen service) by using the  docker restart axigen command.

3. Updating an Axigen Image to the Latest Version Available

Use the following command to update your local axigen/axigen image to the latest version:

After an image is updated, you will need to recreate the axigen instance with an existing axigen data volume as described below.

4. Deleting a Container

The administrator may delete an Axigen container (without deleting the actual data — configuration and domains, which is stored in the Axigen data volume).

A stopped Axigen container may be deleted by using the docker rm axigen command. Please note that only stopped containers may be deleted.

Along with the container, all data which is not Axigen data volume (e.g. shell history, system logs) will be lost.

5. Recreating an Axigen Instance with an Existing Axigen Data Volume

If the Axigen data volume was preserved, a new container may be created using the same volume; the admin password, configuration and domain data will be preserved. The same command as for the initial instance creation is used, but providing an existing, populated Axigen data volume as the fist parameter in the -v mapping.

This method is also used for the following purposes:

  • Upgrading to a newer version of Axigen

  • Recreating the container ↔ host port mapping

6. The Axigen Data Volume

Using a host filesystem path (bind mount)

A directory on the host must be created. If selinux (for Linux hosts) is used, the folder must be labeled with the svirt_sandbox_file_t selinux label.

Example:

This way, the administrator may access files from the axigen var partition (logs, configurations) without accessing the Docker container itself.

Since Axigen is accessing (reading / writing) files in the data volume, it is imperative that the administrator does not modify files in the mapped host folder, as this action may have unpredictable results.

More information about Docker bind mounts here: https://docs.docker.com/storage/bind-mounts/

Using a Docker Volume

A persistent Docker volume may be used. If it does not exist, it will be automatically created on the container instantiation.

More information about Docker volumes here: https://docs.docker.com/storage/volumes/