Miab running in Docker Container

Hey Guys,
I need to run multiple server parralel and got a single powerful. I search for guys who adopted Miab for themselfs in a docker container. I know that it is a unsupported modification and i should not do it because i am in matter of compatability on my own. But i need and want to seperate my services with low ressources consumption. I tried to make it myself but the ubuntu image lacks even with the needed packages in interpreting python in runtime.(I have no clue of python programming) I hope someone of you awesome guys can help me with knowledge.

I tried a few times for learning exercise. End result - couldn’t find a workable solution so looks like standalone server is needed and a shame I cant have one server doing multiple functions which seems to be where you are headed.

When I tried Docker, it felt like a bad fit as a platform as MiaB assumes it is in control of the whole machine and wants to control Hostname, DNS and Firewalls which all require adjustments to get going. Ended up doing so many modifications to the setup script, it didn’t really felt managable and ultimately felt too much trouble and I gave up.

As an alternative, I did tried a VM which worked much better - however I couldn’t find a VPS provider that can really do nested VM and so dead end as well.

My approach for the problems hostname and Firewalls
docker run -d -p 25:25 -p 443:443 -p 80:80 -p 993:993 -p:465:465 -p 587:587 -h “mydomain.lol” -ti --ip “myadress” --ip6 “myadress” --restart=always --name=miab_test ubuntu

and the needed packages and setup commands:

apt-get update -y
apt-get upgrade -y
apt-get install wget sudo curl systemd lsb-core fail2ban nano python-pip netcat-openbsd sed bind9-host locales -y
locale-gen en_US.UTF-8
apt-get purge vim* -y
pip install utils
curl -s https://mailinabox.email/setup.sh | sudo -E bash

but it does interpret phython strange: Can not resolve the paths of the other functions (/setup/preflight.sh does not work - solution: /root/mailinabox/setup/preflight.sh) and at least says that it can not see the ip adress even when the command line at the end of the error messages output both ip s

I got a new update at my optimisation work for docker. I checked other guys who tried the same thing and took some small different approches and added it into my current attempt.

I could resolve the finding ip address problem, by installing beside the in a another earlier post mentioned packets also dialog, net-tools and iproute2. [1]

I still have no idea where to find the part of the script what wants to change hostname and if the python folder resolving problem still exists. Does somebudy know what part takes care of the hostname. I will figure it out when i got the hostname override take out by myself.

[1] Mail-in-a-box in Docker?

@JoshData @murgero what script wants to change the hostname?

Has nobudy here an idea what script is managing the hostnames?! I am not familiar with python but i could not find it myself.

The initial query/variable gets set in “questions.sh” and suggest you intercept that and do you mod just after the question. IT is from line 71 onwards.

The variable gets used various places later but “system.sh” is where it looks like it is calling hostname command to change things

Hope that answers your specific query but as mentioned, going to get more challenging with other pieces and best of luck with it!

Thank you very much for your tip! I will look if strong I need to modyfing everything. I would say that from this point, I now either make a change of the github main project that is needed or i make my own fork of the project to make it portable. The question after the installation will be how to make maintaining possible if it would become a fork.

Notes about this “project”:

  • Maybe usage of Alpine as an image, because it is way better in image size and Storage I/O (lower) but depends on others to port packages over from ubuntu to alpine.
  • When Alpine is used i would need to spoof lsb_release !
  • Maybe just split the main installation and use the single scripts?
  • It makes me very sad that the maintainer of this project did not answer this question… even when he helps a lot and frequently in other questions. (Is this soo off-topip?). It would be cool when readers of this Problem would give some reaction because from now 131 viewer nobudy answerd even if it would be useful to maintain more than only Ubuntu on a root server.:grin:
1 Like

On the maintainers - be fair to them; they have put in a lot to come up with a useful little package for everyone to use and it is free so cannot really have demands or expectations that personal needs be met.

I think the docker thing was not considered in the past because it runs contra to fundamental tenets of the project (basically MiaB wants to in be control of the whole machine; and in this case even a VM is not enough)

Anyway, best of luck with your side project.

@Doc

Hey man,
I see you are planning to run multiple services on a single machine together with MiaB,

I’m planning to do the same.

The environment is pretty simple.

  • Cloudflare as DNS
  • DigitalOcean Droplet as VPS
  • Ubuntu 18.04 as the OS
  • Docker
  • Caddy as the reverse proxy running as container.
  • some HTTP servers for my subdomains running as containers

In my view, I just need to:

  • Create a subdomain for the MiaB
  • Bind more ports to the reverse proxy, meaning the necessary ports for MiaB
  • Forward the mail subdomain to MiaB running as a container.

I would like some guidance/clarification about my approach/understanding.

Thanks.

The Idea is good but the thing about this entire post is that at least at my approaches is that the entire setup script is not runnable for docker. There are some heavy modifications that needs to be done in order to start the installation script.

Things that will probably never been solved by me at least(i am no developer):

  • Getting the admin interface working
  • Making backups like they should be in standard installations

Docker is designed for application containers, and what you want is a system container like systemd-machined or LXC/LXD.
I run MiaB inside an LXD container with Ubuntu 18.04 image, and it works perfectly fine. Make sure to install ssh daemon inside the container because MiaB setup fails if it’s missing. Other than that, it works exactly as on regular VPS.

1 Like

I took your advice and also started running in an LXC/LXD container. After setting up lxd_proxy for all the required ports everything worked perfectly. Great way to save money reducing the number of VPS I need to buy, while maintaining separation between any “static” sites hosted by MiaB and application logic which you can reach on another LXD container via nginx reverse proxies. Seems so far to be a great way to handle all the domain and SSL stuff and still have custom websites with server-side logic in a separate container.

Make sure to setup proxy with nat=true option, otherwise MiaB won’t be able to learn source IP address of the connections, which is essential for port 25.

1 Like

Thanks so much man I totally missed this part :slight_smile:
Also I needed to set a static ip on the “nic” for nat=true.

lxc config device override miab_container_name eth0 ipv4.address=$miab_ip

I have been trying this out GitHub - mxts/mail-in-a-docker: Mail-in-a-Docker (MIAD) helps you run Mail-in-a-Box (MIAB) in a docker container, making it easy to run other services on your box that won't break when you update MIAB. The aim is to make it suitable for production use.