14 PHP containers php_1, ..., php_14
and 14 NGINX containers nginx_1, ..., nginx_14
are running on a server. The PHP container php_i
is only connected to nginx_i
and all NGINX containers are connected via a shared external network. Therefore php_i
can see nginx_i
and nginx_i
can see every nginx_j
.
A new requirement has been added to the system, and we need to have a global Elasticsearch for all projects, allowing all PHP projects to write on this single Elasticsearch instance, which is going to be installed via Docker.
To accomplish this task, the following methods have come to my mind, but I'm unsure which one is the best approach.
- Install an isolated Elasticsearch instance and publish its port, say
9200:9200
, on the host, and in PHP configuration I set the IP of the host, say172.17.0.1
, and port9200
- I can create a dedicated external network for connecting PHP to Elasticsearch, and include this dedicated network in the
networks
directive of the docker-compose file.
I would like to know which method is the best practice.