6
SmarterMail Docker Image
Idea shared by Colin M - 2/4/2019 at 9:33 AM
Completed
Docker is quite well supported now by Microsoft; they even package IIS and SQL Server in Docker containers.


Having SmarterMail in a Docker container would make it easy to perform upgrades, rollbacks (obviously assuming the data was backed up or compatible), and perhaps most importantly, test pre-release versions.

I'd love to test SmarterMail 17 right now but the hassle of installing and uninstalling, mucking with IIS settings, and risking messing up something on a production or secondary server is too much. If SmarterMail were a Docker container it would be trivial to try new versions on my laptop or a remote server, even on the production server using an alternate port.

Docker is not a toy or the latest fad, it is the way of the future and I think Microsoft's strong embrace is good proof of that. Installing your mail server by remoteing in with RDP to "double-click" an MSI installer is the way of the past and for very good reasons.

Not entirely related, but in a similar vein of reasoning, built-in Let's Encrypt support would be awesome as well.

16 Replies

Reply to Thread
2
Matt Petty Replied
Employee Post
I got a windows container version working a couple months ago. I also added a "mail-root" startup argument onto MailService.exe. This allows you to load off of an external system directory instead of the usual C:\Program Files (x86)\SmarterTools\SmarterMail\Service.

I HAD to add that setting into SmarterMail to support docker containers otherwise your system files would be stored IN the container. Using this "mail-root" for a custom service directory and a custom data path (not C:\SmarterMail), allows your container to not house any SM data except for the files necessary to run SmarterMail, while system config and data would all be externally stored.

This setting is now in SM 16 and 17 and has been for months since I added it in, purely for docker support. When I get some time I may document the process of creating a container and maybe even setup something automated. I've been looking to learn the Azure pipeline/project stack for a while now, this would give me a chance to get my feet wet with automating docker builds.

EDIT: I added in that mail-root as a test for getting docker to work. I figured it was useful so I left that mail-root option in, BUT it has been months since I tried that mail-root argument so heads up, things may break if you use it.
Matt Petty Software Developer SmarterTools Inc. www.smartertools.com
0
Thanks for the info, Matt. While I'm very experienced with Docker, my experience is basically limited to Linux platform so I'm not really interested in pioneering my own Docker image. An officially-supported Docker image is what I am advocating and it sounds like there are no real blockers; just some testing, tweaking, documentation and pushing an image somewhere (Docker Hub being the obvious choice).

While there may not be a lot of people begging for this, if you had a solid Docker image I think pretty quickly people would adopt using it since the installation would be only a few steps:

- Enable "Containers" in the Windows features dialog if not enabled already.
- Create a volume for the data.
- Create a new container with the "smartertools/smartermail:17.x-beta" image.
- Profit.

Although my preferred method of managing containers is Docker Compose due to the readability as the config gets more complex, the first step is getting a basic working image out there. For it to be usable in production it will definitely need to support HTTPS/SSL, though.
1
Wondering if there has been any traction here - I'm currently maintaining an Azure VM strictly for SmarterMail - I would love to switch this over to a container.   A guide would be nice :)
0
Kyle Kerst Replied
Employee Post
@Robert - I think this is still an excellent suggestion - but is likely something development has not had a chance to revisit due to our focus on MAPI and other areas we're still fine tuning on our end. I did find some documentation on creation of Docker images (linked below) but am not familiar enough with these procedures to provide much in the way of specific guidance: 


If you do get this sorted out please ping me/support as we'd be happy to take a look and get this published as an official KB. I hope this helps! Have a good one!
Kyle Kerst System/Network Administrator SmarterTools Inc. www.smartertools.com
0
Has anyone made any progress on a docker image that can run SmarterMail?
0
Hello,
@Matt Patty is it possible for you to share the Docker-File?
0
I am very interested in this too.  Please share the docker file. 
1
I made a dockerized version of the Linux beta based on the Ubuntu docker image, feel free to do with it what you want. I do not recommend production usage. I did some tests, and it seems to work quite well.

This is the host mode version (recommended)
services:
  smartermail:
    image: peppershade/smartermail:8930
    network_mode: "host"
    environment:
      - TZ=Europe/Berlin
    volumes:
      - ./maildata:/var/lib/smartermail
      - ./mailconfig:/etc/smartermail
Docker network version
services:
  smartermail:
    image: peppershade/smartermail:8930
    # Set the timezone to your local timezone (IMPORTANT)
    environment:
      - TZ=Europe/Berlin
    ports:
      - 80:80
      - 443:443
      - 587:587
      - 110:110
      - 143:143
      - 993:993
      - 995:995
    volumes:
      - ./maildata:/var/lib/smartermail
      - ./mailconfig:/etc/smartermail
Make sure to create a docker-compose.yml file, and create the folders maildata and mailconfig in the same folder.

Edit: The source is on GitHub, but I'm not allowed to add it in this reply. Search for repo Peppershade/SmarterMail-Docker
4
Zach Sylvester Replied
Employee Post
Hello, 

We have also been working on a Docker image for SmarterMail. You can find it on Docker Hub here. 

I hope this helps. 😊
Zach Sylvester Software Developer SmarterTools Inc. www.smartertools.com
0
Zach,
If you configured the ports section of the compose section in long syntax, it would help those of us who know nothing about docker and/or compose files to understand what's going on. And anything else that has long vs short syntax. (I only know long syntax exists because I was googling for clarification on what you meant by "<fill in web port>")
1
Zach Sylvester Replied
Employee Post
Hey Patrick, 

Thanks for the question. The right side of the input refers to what is set inside the docker container this must match the port for the application. The left side refers to what is exposed. 

So say for you instance you wanted to use port 8282 instead of port 80 you could do something like this.


ports:
      - "8282:80"
      - "25:25"
      - "110:110"
      - "143:143"
      - "465:465"
      - "587:587"
      - "993:993"
      - "995:995"
      - "5222:5222"

Then you go to localhost:8282 you will reach SmarterMails HTTP port. 

One thing that you will also notice is that I removed the 443 SSL ports. This is ok to do as it just means that they will not be exposed from the container. 

Please let me know if this makes sense. 

Thanks, 
Zach Sylvester Software Developer SmarterTools Inc. www.smartertools.com
1
Matt Petty Replied
Employee Post
In most cases, if your hosting the container without a proxy in front of it you can just do
- "80:80"
- "443:443"
- "443:443/udp"
(http3 can use udp)

SmarterMail https wont work until you add in atleast 1 domain and turn on certificate generation. Once we have a certificate for that domain it will be used automatically for web connections (and SMTP, IMAP, etc)

Some people might have a nginx/caddy server that sits in front of all their services handling the certs and routing. In this case you can just do, this for example and then route internally to X.X.X.X:8282
- "8282:80"
Matt Petty Software Developer SmarterTools Inc. www.smartertools.com
1
Zach,
I was easily able to find information on compose file ports, I was just making the suggestion that from what I found, the long syntax is more readable for those like me that aren't well versed with docker. Thanks for the explanation though. Every bit helps.
0
I don't use SmarterMail anymore, but I'm still glad to see you finally added a Docker image. To encourage uptake I'd strongly recommend adding out of the box configs such as:

  • Include an example of Caddy as a frontend in the Docker Hub page. It should be possible to change one variable (the public host name) and then "docker compose up" - then write a blog post about it.
  • Submit apps or quick start templates for platforms like Coolify, Dokku, Fly.io, Digital Ocean
  • Look into other platforms that are used for self-hosting like Raspberry Pi, QNAP and Sonology NAS, etc. This may not be your target market but the effort should be minimal now that you have a base Docker image.
Persistent storage is one challenge for hosting SmarterMail still. Managing backups is a PITA and most probably aren't doing it right. This is why platforms like Fly.io with Fly Volumes could be a really powerful combination - set up your SmarterMail server on a low-cost yet scalable platform that provides automatic backups and you could have a winner. But there are also other good solutions and I'd recommend making backup/restore an out of the box feature - this should be easier now as there are tools to backup Docker volumes.

Even for the folks that want the old-school experience of managing a full server, I'd strongly encourage Docker Compose as the way to go. IIS, MSI installers, Windows - it just sucks and even Microsoft agrees. So I'd also suggest writing a guide on how to migrate existing installations over to a docker-based platform whether it be the cloud, the same server (data would not even have to be moved), etc.

As a user of SmarterMail for many years, I think the cost/management/risk of a Windows server plus trying to stay ahead of spammers was what drove my clients to services like Google and Azure.
1
Also the firewall can easily be dockerized and added to the Docker Compose file so you don't need to provide instructions for specific firewalls like ufw - that's just more friction for adoption. See here: https://github.com/colinmollenhour/docker-confd-firewall
0
Matt Petty Replied
Employee Post
Thanks for all that information, I'll make sure to read through it and make some suggestions.
I've got SM experimentally running on an ARM board here, https://portal.smartertools.com/community/a96260/smartermail-running-on-an-orange-pi-zero-3-arm_.aspx
(it's been running on my desk off a usb for the past couple weeks, I had to restart it once.)

I've actually been using fly.io quite a bit personally and for some development experiments. I'll definitely try to put together a complete Fly guide. Though I think I ran into some challenges with their routing because outbound requests come from random IP addresses but some of that might be more configurable now. A DigitalOcean template or setup would be good too I've used that off and on in the past. I also use Unraid at home and that is a pretty cool platform as well with a plugin/app repository.
Matt Petty Software Developer SmarterTools Inc. www.smartertools.com

Reply to Thread