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-compose when a container is started WARNING: Found orphan containers
  • How to see a docker container using a number of server resources ah?
  • Docker-compose.yml can specify the local mirror, I found to docker.io pull the mirror too slowly
  • Docker-compose problems in the volume
  • Docker overlay always 2 days to put the hard disk to eat .... what is the reason?
  • Docker-compose why can not find the configuration file?
  • Use the docker-compose to write a regular lnmp container, pdo connect mysql fails with error number 2002.
  • Docker burst failure, `aufs: device or resource busy`, unable to start the container
  • 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.