Run your favorite mail client mutt in a Docker container without installing mutt on your host system.
The fstab/mutt docker image contains only the mutt and msmtp applications, but no configuration. The configuration must be created in a directory on the host system and mounted as a volume to /home/mutt
in the container.
On the host system, create a folder ~/.mutt/
. In this folder, create the configuration files as follows:
msmtp is a sendmail replacement that can be used for sending mail via an SMTP server. It is configured on the host system in a file ~/.mutt/.msmtprc
as follows:
defaults
logfile ~/.msmtp.log
account alice
host mail.example.com
from [email protected]
auth on
user alice
password xxxxxxxx
account default : alice
mutt is configured on the host system in ~/.mutt/.muttrc
.
#########################
# sending with msmtp
#########################
set sendmail="/usr/bin/msmtp"
set use_from=yes
set realname="Alice Springs"
set [email protected]
set envelope_from=yes
#########################
# receiving with imap
#########################
set folder="imaps://alice:[email protected]"
set spoolfile="+INBOX"
set record="+Sent"
set postponed="+Drafts"
set trash="+Trash"
set header_cache = "/home/mutt/.mutt_cache"
set message_cachedir = "/home/mutt/.mutt_cache"
# Automatically poll subscribed mailboxes for new mail (new in 1.5.11)
set imap_check_subscribed
# Reduce polling frequency to a sane level
set mail_check=60
#########################
# usability
#########################
set editor="vim"
Create the mutt cache directory ~/.mutt/.mutt_cache/
on the host system and change access rights of ~/.mutt/
to 700
.
A pre-built image is available on Docker Hub. Once the configuration is created on the host system, the container can be run as follows:
docker run -v ~/.mutt:/home/mutt -t -i fstab/mutt
The container will start up with the mutt mail client.
-
Make sure Docker is installed.
-
Clone fstab/docker-mutt from GitHub.
git clone https://github.com/fstab/docker-mutt.git
-
Build the docker image
cd docker-mutt docker build -t="fstab/mutt" .
-
Once the configuration is is created on the host system, the docker container can be run as follows:
docker run -v ~/.mutt:/home/mutt -t -i fstab/mutt
If everything works fine, add an alias to the ~/.bashrc
so that the container can be run with a simple mutt
command:
alias mutt="docker run -v ~/.mutt:/home/mutt -t -i fstab/mutt"