简体   繁体   English

错误连接被拒绝:Docker Rails 中的 MailCatcher

[英]Error Connection Refused: MailCatcher in Docker Rails

I have Rails application running in Docker, and I want to integrate mailcatcher for development.我有在 Docker 中运行的 Rails 应用程序,我想集成 mailcatcher 进行开发。

docker-compose.yml docker-compose.yml

version: '3'
services:
 db:
  image: postgres:alpine
  restart: always
  volumes:
   - postgres-data:/var/lib/postgresql/data
  ports:
    - "9000:5432"

 app:
  build: 
    context: .
    dockerfile: ./docker/app/DockerFile
  restart: always
  command: bash -c "rm -f tmp/pids/server.pid && rails s -p 3000 -b '0.0.0.0'"
  volumes:
   - .:/vsapp-cms-backend
   - bundle_path:/bundle
  environment: 
    - BUNDLE_PATH=/bundle/vendor
  ports:
    - "3002:3000"
  depends_on:
    - db

 mailcatcher:
  image: schickling/mailcatcher
  ports:
    - "1080:1080"
    - "1025:1025"

volumes:
  bundle_path:
  postgres-data:

development.rb发展.rb

config.action_mailer.delivery_method = :smtp

config.action_mailer.smtp_settings = { 
    address: '127.0.0.1',
    port: 1025 
}

I can see the mailcatcher is also running on http://localhost:1080 but when I run UserMailer.send_invite(user).deliver_now!我可以看到 mailcatcher 也在http://localhost:1080上运行,但是当我运行UserMailer.send_invite(user).deliver_now!

I'm getting我越来越

Errno::ECONNREFUSED: Connection refused - connect(2) for "127.0.0.1" port 1025

I managed to send it by changing the address from development.rb to mailcatcher我设法通过将地址从development.rb更改为mailcatcher来发送它

config.action_mailer.delivery_method = :smtp

config.action_mailer.smtp_settings = { 
    address: 'mailcatcher',
    port: 1025 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM