我有一个要用于整个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.yml
时my_web_container
可以正常运行。为什么网络中无法访问端口1025
?