错误连接被拒绝:Docker Rails 中的 MailCatcher
Error Connection Refused: MailCatcher in Docker Rails
我在 Docker 中有 Rails 应用程序 运行ning,我想集成 mailcatcher 进行开发。
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
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: '127.0.0.1',
port: 1025
}
我可以看到 mailcatcher 也在 运行ning 上 http://localhost:1080
但是当我 运行 UserMailer.send_invite(user).deliver_now!
我正在
Errno::ECONNREFUSED: Connection refused - connect(2) for "127.0.0.1" port 1025
我通过将地址从 development.rb 更改为 mailcatcher
成功发送
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'mailcatcher',
port: 1025
}
我在 Docker 中有 Rails 应用程序 运行ning,我想集成 mailcatcher 进行开发。
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
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: '127.0.0.1',
port: 1025
}
我可以看到 mailcatcher 也在 运行ning 上 http://localhost:1080
但是当我 运行 UserMailer.send_invite(user).deliver_now!
我正在
Errno::ECONNREFUSED: Connection refused - connect(2) for "127.0.0.1" port 1025
我通过将地址从 development.rb 更改为 mailcatcher
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'mailcatcher',
port: 1025
}