Sending email from docker through Postfix installed on the host

We use MUP to deploy our Meteor app, NYBR. MUP creates three docker containers for running the meteor app, nginx reverse proxy and mongo. Like most applications, the need for sending the email came, ideally we should be using Amazon Web Services SES,  but getting their approval was a pain in the @$$ and was taking time. So, we did not want to hold back our development and decided to send the email through our own SMTP server until SES was approved.

We installed postfix and were hoping to get to developing and sending beautiful emails to our users. Unfortunately, we were greeted with the Connection refused error.

After trying various things in postfix configuration at,/etc/postfix/ turns out there is something called docker bridge (docker0) which acts a bridge between your ethernet port and Docker containers so that data can go back and forth.

So you have to listen on the docker0 interface. To do that, type ifconfig on your host system to find out the bridge address and set your postfix to listen on it.

Docker Bridge address

As you can see in the image above, the IP is

In postfix configuration located at /etc/postfix/ set

inet_interfaces =

While you are there, add your actual docker container ip address to mynetworks

mynetworks =

above two are private ip addresses of my docker containers from which I wish to send email.

You can find the IP address of your docker container by

docker inspect [container_id, container_name]


docker inspect my_container_name

Let me know in comments if you would like to learn how to send html emails in meteor.

2 Replies to “Sending email from docker through Postfix installed on the host”

  1. So, now I know how to configure my host’s postfix installation. But do I need to install something inside the container, like postfix? Let say I run an ubuntu:latest container. I don’t have sendmail installed, so I install postfix (which provides its own sendmail implementation). But then how do I configure the container’s postfix installation?

    I have quite a hard time understanding how all this works ^^

    1. You don’t have to install or configure containers postfix or sendmail. The container asks the host to send an email, and we have configured postfix to accept requests from the container.

Leave a Reply

Your email address will not be published. Required fields are marked *