ruby-on-railsdocker-composemailcatcher

docker compose rails 6 example with mailcatcher doesn´t work


I have this file "docker-compose.yml"

    version: '3'

    services:

    web: 
        build: .
        #command: bash -c "foreman start -f Procfile.dev-server"
        ports:
            - "3000:3000"

        volumes:
            - .:/app  

        environment:
            DATABASE_HOST: database
            POSTGRES_USER: postgres
            POSTGRES_PASSWORD: miclave
            POSTGRES_DB: myapp_development  

        links:
            - mailcatcher    

        depends_on:
            - database 
        stdin_open: true
        tty: true
    database:
        image: postgres 
        ports:
            - "5432:5432"
        volumes:
            - .:/app   
        environment:
            POSTGRES_USER: postgres
            POSTGRES_PASSWORD: miclave
            POSTGRES_DB: myapp_development

    mailcatcher:
        image: zolweb/docker-mailcatcher:latest
        ports:
            - "1025:1025" 
            - "1080:1080"  

When I try to send an email from my ruby on rails web app I get this error:

enter image description here

Can anybody help me to find out what I am doing wrong?. Thanks


Solution

  • This is because you can't access service through 127.0.0.1. If your services on the same network you will able to access it by the links directive you passed, like change your address from 127.0.0.1 to mailcatcher. If your services in different networks - you can open ports on service that you need to call and then access it by machine local ip address (not the 127.0.0.1 but by the your physical/virtual machine ip address in local network)