Dockerize Mail Sender

TurnToJPG -->

In DigitalOcean VPS, which runs the Ubuntu 14.04.1 LTS, setup a mail sender server.


Install the via:

# apt-get install

Git clone the repository from the github, configure it and build the container:

# pwd
# git clone
# ls
# cd dockermail
# cat mail-base/domains 
# cat mail-base/passwords{PLAIN}password123{SHA256-CRYPT}$5$3qaCC/fV65Adtfoy$O20EXoSOcgWKf5NyAZnXAtGPQoSgeYRjLm56M25.H12
# make

Run the containers:

root@lilimarleen:~/code/docker_mail/dockermail# make run-all
docker run -d -p -p -p -v /srv/vmail:/srv/vmail dovecot:2.1.7
docker run -d -p rainloop:1.6.9
docker run -d -p -v /srv/owncloud:/var/www/owncloud/data owncloud:7.0.2 
root@lilimarleen:~/code/docker_mail/dockermail# docker ps
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS                                                            NAMES
9e62a4f6140c        owncloud:7.0.2      /bin/sh -c 'cp -npr    3 seconds ago       Up 2 seconds>80/tcp                                          backstabbing_sinoussi   
e7246bcf39dd        rainloop:1.6.9      /bin/sh -c 'apachect   3 seconds ago       Up 3 seconds>80/tcp                                          sad_sinoussi            
4dac1e99be85        dovecot:2.1.7       /bin/sh -c 'chown -R   3 seconds ago       Up 3 seconds>25/tcp,>143/tcp,>587/tcp   evil_ptolemy      


Use nsenter for entering the running container:

# Ubuntu 14.04 don't have nsenter - the straight forward way required me to install build tools and etc.
# I preferred to keep the system clean and install nsenter in a container and then copy the command to the host
# Note - its also possible to run nsenter from a container (didn't tried)

# start a container
docker run --name nsenter -it ubuntu:14.04 bash

## in the docker
apt-get update
apt-get install git build-essential libncurses5-dev libslang2-dev gettext zlib1g-dev libselinux1-dev debhelper lsb-release pkg-config po-debconf autoconf automake autopoint libtool

git clone git:// util-linux
cd util-linux/

./configure --without-python --disable-all-programs --enable-nsenter

## from different shell - on the host
docker cp nsenter:/util-linux/nsenter /usr/local/bin/
docker cp nsenter:/util-linux/bash-completion/nsenter /etc/bash_completion.d/nsenter

Thus you have the nsenter.

Enter the container

Get the PID via:

# docker inspect --format "{{.State.Pid}}" a66adc0e63fc

Enter the docker container and view the status:

# nsenter --target 24740 --mount --uts --ipc --net --pid -- /bin/bash

Why we want to enter this terminal? Because we want to view the password of the admin. The configuration file says:

# cat mail-base/passwords{SHA256-CRYPT}$5$3qaCC/fV65Adtfoy$O20EXoSOcgWKf5NyAZnXAtGPQoSgeYRjLm56M25.H12

If you met “port has been occupied”, you should do like following:
Remove all of the containers:

# docker ps -a | grep "ago" |  awk '{print $1}' |  xargs --no-run-if-empty docker rm

Trouble Shooting

First you should add corresponding MX record in you domainname service provider.