I have a NodeJS application packed in a Docker container from which I send email to smtp.gmail.com
(using nodemailer
npm library). The same container (I mean same image pulled from same registry) works on my Macbook, but throws timeout error on my Ubuntu VPS. I tried to ping smtp.gmail.com
from Ubuntu container using docker exec...
, and the ping works fine. I wonder what is the problem. Here are the details -
My Macbook:
- OS: MacOS High Sierra (Version 10.13.6)
- Docker: Version 18.06.1-ce, build e68fc7a
Ubuntu VPS:
- OS: Ubuntu 16.04.5 LTS
- Docker: Version 18.06.1-ce, build e68fc7a
Error:
On Ubuntu machine I start the container using command docker run -p 7656:7656 fb
. And the error I get is -
{ Error: Connection timeout
at SMTPConnection._formatError (/docker-training/node_modules/nodemailer/lib/smtp-connection/index.js:606:19)
at SMTPConnection._onError (/docker-training/node_modules/nodemailer/lib/smtp-connection/index.js:579:20)
at Timeout._connectionTimeout.setTimeout (/docker-training/node_modules/nodemailer/lib/smtp-connection/index.js:261:18)
at ontimeout (timers.js:478:11)
at tryOnTimeout (timers.js:302:5)
at Timer.listOnTimeout (timers.js:262:5) code: 'ETIMEDOUT', command: 'CONN' }
My Docker file -
FROM node:9.2.0
RUN mkdir /docker-training
WORKDIR /docker-training
COPY . ${WORKDIR}
RUN ["npm", "install"]
EXPOSE 7656
ENTRYPOINT ["npm", "start"]
Any help is appreciated.