如何在Docker网络中将邮件发送到Mailhog容器

时间:2018-11-13 12:02:20

标签: docker docker-network

我有一个要用于整个Docker网络的mailhog容器。配置看起来像这样:

version: '2'

services:
    my_nginx_proxy:
        container_name: my_nginx_proxy
        restart: always
        networks:
            - my_network
        image: jwilder/nginx-proxy
        ports:
            - 12002:80
    my_mailhog:
        container_name: my_mailhog
        image: mailhog/mailhog:v1.0.0
        restart: always
        networks:
            - my_network
        ports:
            - 12401:8025

networks:
    my_network:
        external:
            true

网络中的其他容器具有以下配置:

version: "2"

services:
    my_web_container:
        container_name: my_web_container
        image: php
        restart: always
        links:
            - db_container:mysql
        external_links:
            - my_mailhog:mailhog
        networks:
            - my_network
        depends_on:
            - db_container

networks:
    my_network:
        external:
            true

当我尝试从Web容器使用主机mailhog和端口1025发送邮件时,出现连接错误。当我将my_mailhog配置添加到下面的docker-compose.ymlmy_web_container可以正常运行。为什么网络中无法访问端口1025

0 个答案:

没有答案