Can't prikonektitsya to elasticsearch using Docker, what could be the reason?

These options are unable to create a connection with b.d.:localhost,, simpledocker2_elastics
In Http.php line 187:
<i>couldn't connect to host, Elasticsearch down?</i>

ERROR [elastica] Elastica Request Failure ["exception" => Elastica\Exception\Connection\HttpException { ...},"request" => ["path" => "app","method" => "DELETE","data" => [],"query" => [],"contentType" => "application/json","connection" => ["config" => ["headers" => [],"curl" => []],"host" => "","port" => 9200,"ssl" => false,"logger" => "fos_elastica.logger","compression" => false,"retryOnConflict" => 0, 'enabled' = > false]],"retry" => false]

 default: { host:, port: 9200}
April 4th 20 at 13:24
2 answers
April 4th 20 at 13:26
Need to add links to php-fpm in docker-compose.yml and connect to:

$hosts = [

$client = a clientbuilder produces::create()->setHosts($hosts)->build();
April 4th 20 at 13:28
What is the second config? host is indicated only in the parameters of the elastic server to "listen" for all addresses, not in any particular. The client must specify EITHER the IP address of elastica (host or container) OR the container name (service) - if the elastic is running in the container

localhost and for the container is, quite logically, that same container. Which of COURSE the elastic is not running. Therefore, it makes no sense to do. The only exception is when the containers are run without isolation network (--net host)

Find more questions by tags SymfonyElasticsearchDocker