Two docker-composer, one is the php environment, one is the elastic environment, how to connect the two?

1. Because PHP environment has long been built, and now the business needs to use elasticsearch.
2. Now a new docker-composer is built to build the elk environment.
3. The container gateway created by the two is different.

Php7
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.6",

Elasticsearch
"Gateway": "172.19.0.1",
"IPAddress": "172.19.0.2",

Question: how can i make the php environment connect to the elasticsearch service?

  • Docker official mirror mostly based on debian, but the official source update failed, how to replace the source of China?
  • What is the difference between dockerfile and docker-compose?
  • Pointing to the compose file is correct, the container name did not take effect
  • Docker-compose why can not find the configuration file?
  • Docker overlay always 2 days to put the hard disk to eat .... what is the reason?
  • Docker-compose how to specify the directory, similar to the dockerfinle WORKDIR instruction
  • Docker-compose.yml How do I update an existing Container after modification?
  • Docker-compose problems in the volume
  • 2 Solutions collect form web for “Two docker-composer, one is the php environment, one is the elastic environment, how to connect the two?”

    Add to the same network on it, compose in the description of the network, you can see

    Through the expose instruction to the container internal port mapping and host port mapping, so that the container can access the host IP + Port way to access the corresponding container of the internal service. – this is docker network mode bridge mode;

    Of course, you can also set the net = host, disable the docker container network isolation, using shared host network namespace way, so there is no container and container network communication problems. – this is the host mode;

    Of course, there are other models, you can go to understand the docker network mode related content.

    Heads up! This alert needs your attention, but it's not super important.