Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Communication between two ddev projects

Tags:

ddev

I got two ddev projects that needs to interact with each other. When a ran into some issues, I check the resolved IP for the connection. I did it by ssh into project1 and ping project2 (ping project2.ddev.local) The domain resolves to 127.0.0.1 So every request I send to this domain will stay in the current container and is not routet to the other project.

Steps to reproduce: Start two separate ddev containers and ssh into one of them. Try to ping the the other project by using the ddev domain.

Is there a solution that two (or more) projects can interact with each other?

like image 697
Tim Schreiner Avatar asked Mar 19 '26 09:03

Tim Schreiner


2 Answers

2025 Update: it works out-of-the-box in DDEV v1.24.10+ without any extra external_links configuration

Previous answer:

This is covered in the DDEV FAQ:

Yes, this is commonly required for situations like Drupal migrations. For the web container to access the db container of another project, use ddev-<projectname>-db as the hostname of the other project.

Let’s say we have two projects, for example: project A, and project B. In project A, use mysql -h ddev-projectb-db to access the database server of project B. For HTTP/S communication (i.e. API calls) you can 1) access the web container of project B directly with the hostname ddev-<projectb>-web and port 80 or 443: curl https://ddev-projectb-web or 2) Add a .ddev/docker-compose.communicate.yaml to project A to access project B via the official FQDN.

services:
  web:
    external_links:
      - "ddev-router:projectb.ddev.site"

This lets the ddev-router know that project A can access the web container on project B's DDEV URL. If you are using other hostnames or project_tld, you will need to adjust the projectb.ddev.site value.

like image 77
rfay Avatar answered Mar 22 '26 08:03

rfay


As per the documentation https://ddev.readthedocs.io/en/latest/users/usage/faq/#can-different-projects-communicate-with-each-other, the web container of any project can be accessed by another project by following the pattern https://ddev-<PROJECT-NAME>-web. In Drupal, if you are using the entity_share module and want to add one website as a client then you can add https://ddev-<CLIENT-PROJECT-NAME>-web and it will work.

like image 40
MutantMahesh Avatar answered Mar 22 '26 10:03

MutantMahesh