我正在学习如何将 Docker 与多个容器一起使用,而不是单个容器。
我想学习如何从容器 A 调用位于容器 B 上的程序。
(即:我希望能够致电sendmail
从我的web
容器,同时sendmail
和类似的程序位于mailhog
容器。)
我有这个:
docker-compose.yml
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
error.
我怎样才能将两者联系起来?
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)