Docker:在其他容器中找到sendmail [英] Docker : find sendmail in other container
问题描述
我正在学习如何将Docker与多个容器(而不是单个容器)一起使用.
I'm learning how to use Docker with multiple containers, as opposed to a single one.
我想学习如何从容器A调用位于容器B上的程序.
I'd like to learn how to call, from container A, a program located on container B.
(即:我希望能够从web
容器中调用sendmail
,而sendmail
和类似程序位于mailhog
容器上.)
(i.e.: I want to be able to call sendmail
from my web
container, while sendmail
and similar programs are located on a mailhog
container.)
我有这个:
web:
container_name: centosweb
image: fab/centosweb
ports:
- "80:80"
volumes:
# Single files
- ./config/httpd.conf:/etc/httpd/conf/httpd.conf
# Directories
- ./vhosts:/var/www/html
- /Users/fabien/Dropbox/AppData/XAMPP/web/bilingueanglais/public_html:/var/www/html/bilingueanglais
- ./logs/apache:/etc/httpd/logs # This will include access_log(s) and error_log(s), including PHP errors.
links:
- db:3306
- mailhog:1025
db:
container_name: centosdb
image: fab/centosdb
hostname: db
volumes:
# Single files
- ./config/my.cnf:/etc/my.cnf
# Directories
- ./mysqldata:/var/lib/mysql
- ./logs/mysql:/var/log/mysql
mailhog:
image: mailhog/mailhog
hostname: mailhog
ports:
- 1025:1025
- 8025:8025
但是,现在web
找不到/usr/sbin/sendmail
,因为它位于mailhog
容器上.尝试从PHP使用邮件功能会产生Could not instantiate mail function
错误.
However, right now, web
cannot find /usr/sbin/sendmail
since it's located on the mailhog
container. Trying to use a mail function from PHP produces a Could not instantiate mail function
error.
如何链接两者?
推荐答案
容器必须位于同一网络中,这是我的问题.
The containers need to be in the same network, that was my problem.
这篇关于Docker:在其他容器中找到sendmail的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!