我有在 Docker 中运行的 Rails 应用程序,我想集成 mailcatcher 进行开发。
码头工人-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:
发展.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: '127.0.0.1',
port: 1025
}
我可以看到 mailcatcher 也在运行,http://localhost:1080
但是当我运行时 UserMailer.send_invite(user).deliver_now!
我越来越
Errno::ECONNREFUSED: Connection refused - connect(2) for "127.0.0.1" port 1025