docker : find sendmail in other container

标签 docker isolation

我正在学习如何将 Docker 用于多个容器,而不是单个容器。

我想学习如何从容器 A 调用位于容器 B 上的程序。

(即:我希望能够从我的 web 容器调用 sendmail,而 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 错误。

如何将两者联系起来?

最佳答案

容器需要在同一个网络中,这是我的问题。

关于 docker : find sendmail in other container,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43888542/

相关文章:

ios - 成为离线 iOS 开发者

MySQL 事务和并发插入

docker - 有什么办法可以隔离应用程序而无需在Cygwin Windows下使用容器

java - 使用 JTA 隔离分布式(全局)事务

docker - 启用从 Docker 容器到外部世界的转发

azure - 发布到 Azure 应用服务时,Puppeteer 不起作用

java - 如何为具有多个存储库的 IntelliJ 项目编写 Dockerfile?

javascript - 无法通过Nodejs连接到Docker内部的Tarantool容器

mysql - 无法从另一个容器访问Docker容器中的MySQL数据库

VMware Player 12 选项 "guest isolation"缺失