Docker : find sendmail in other container

99封情书 提交于 2019-12-11 02:29:25

问题


I'm learning how to use Docker with multiple containers, as opposed to a single one.

I'd like to learn how to call, from container A, a program located on container B.

(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.)

I have this:

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

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.

How can I link the two?


回答1:


The containers need to be in the same network, that was my problem.



来源:https://stackoverflow.com/questions/43888542/docker-find-sendmail-in-other-container

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!