MySQL server has gone away Docker

OS: centos 8 (mysql 8)

Two docker containers:

  1. MariaDB 10.3 (the database we are indexing)
  2. manticore
    docker run --restart=always --name manticore -p 127.0.0.1:9306:9306 -p 127.0.0.1:9308:9308 -p 127.0.0.1:9312:9312 -d manticoresearch/manticore

Database index it works
docker exec -it manticore gosu manticore indexer --all --rotate

But connecting via php to manticore - does not work

<?php
$m = mysqli_connect('127.0.0.1', '', '', '', 9306);

I have error: MySQL server has gone away

How to fix it?

If you started it like this

docker run --restart=always --name manticore -p 127.0.0.1:9306:9306 -p 127.0.0.1:9308:9308 -p 127.0.0.1:9312:9312 -d manticoresearch/manticore

the indexer command should have failed:

➜  ~ docker exec -it manticore gosu manticore indexer --all --rotate
Manticore 3.5.4 13f8d08d@201211 release
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)
Copyright (c) 2017-2020, Manticore Software LTD (http://manticoresearch.com)

using config file '/etc/manticoresearch/manticore.conf'...
FATAL: no indexes found in config file '/etc/manticoresearch/manticore.conf'

If you started it differently (i.e. had some custom config) please provide it.

To me your script works just fine:

➜  ~ docker ps
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS                                                                                         NAMES
7814db45e82e        manticoresearch/manticore   "docker-entrypoint.s…"   2 minutes ago       Up 2 minutes        127.0.0.1:9306->9306/tcp, 127.0.0.1:9308->9308/tcp, 127.0.0.1:9312->9312/tcp, 9315-9325/tcp   manticore
➜  ~ cat yr4ik.php
<?php
$m = mysqli_connect('127.0.0.1', '', '', '', 9306);
$res = $m->query("show status");
while ($row = $res->fetch_assoc()) print_r($row);

➜  ~ php yr4ik.php|head
Array
(
    [Counter] => uptime
    [Value] => 139
)
Array
(
    [Counter] => connections
    [Value] => 3
)