Install MailCatcher Inside Docker Container in Linux

Install MailCatcher Inside Docker Container in Linux

MailCatcher is an email testing tool that acts as a local SMTP server which accepts incoming email messages that displayed in a web interface. MailCatcher can be useful for testing and debugging purposes, helping developers for inspecting emails that are generated by their application.

This tutorial explains how to install MailCatcher inside a Docker container in the Linux. Commands have been tested on Ubuntu.

Prepare environment

Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.

Install MailCatcher

  • Host network

Run the following command to create a container for MailCatcher that uses host network:

docker run -d --name=mailcatcher --restart=always --network=host \
    dockage/mailcatcher
  • User-defined bridge network

User-defined bridge network can be used for listening on different port. By default, MailCatcher service is listening for SMTP connections on port 1025. Web UI is available on port 1080. Both ports can be changed with -p option.

docker network create app-net
docker run -d --name=mailcatcher --restart=always --network=app-net \
    -p 8080:1025 -p 8081:1080 \
    dockage/mailcatcher

Testing MailCatcher

To access web UI, open a web browser and go to http://<IP_ADDRESS>:1080, where <IP_ADDRESS> is the IP address of the system.

MailCatcher Inside Docker Container in Linux

Uninstall MailCatcher

To completely remove MailCatcher, remove its container:

docker rm --force mailcatcher

Remove MailCatcher image:

docker rmi dockage/mailcatcher

If a user-defined bridge network was created, you can delete it as follows:

docker network rm app-net

Leave a Comment

Cancel reply

Your email address will not be published.