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.
- Docker-compose.yml How do I update an existing Container after modification?
- Docker in docker is directly in the DockerFile direct apt-get install?
- Use the docker-compose to write a regular lnmp container, pdo connect mysql fails with error number 2002.
- Docker-compose.yml can specify the local mirror, I found to docker.io pull the mirror too slowly
- What is the difference between dockerfile and docker-compose?
- Docker-compose problems in the volume
Question: how can i make the php environment connect to the elasticsearch service?
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.