The image is based on current release of Manticore package.
The default configuration includes a sample Real-Time index and listens on the default ports:
9306 for connections from a MySQL client9308 for connections via HTTP9312 for connections via a binary protocol (e.g. in
case you run a cluster)The image comes with libraries for easy indexing data from MySQL, PostgreSQL XML and CSV files.
The below is the simplest way to start Manticore in a container and log in to it via mysql client:
docker run --name manticore --rm -d manticoresearch/manticore && docker exec -it manticore mysql && docker stop manticoreWhen you exit from the mysql client it stops and removes the container, so use it only for testing / sandboxing purposes. See below how to use it in production.
The image comes with a sample index which can be loaded like this:
mysql> source /sandbox.sqlAlso the mysql client has in history several sample queries that you can run on the above index, just use Up/Down keys in the client to see and run them.
For data persistence the folder /var/lib/manticore/
should be mounted to local storage or other desired storage engine.
Configuration file inside the instance is located at
/etc/manticoresearch/manticore.conf. For custom settings,
this file should be mounted to own configuration file.
The ports are 9306/9308/9312 for SQL/HTTP/Binary, expose them depending on how you are going to use Manticore. For example:
docker run --name manticore -v $(pwd)/data:/var/lib/manticore -p 127.0.0.1:9306:9306 -p 127.0.0.1:9308:9308 -d manticoresearch/manticoredocker run --name manticore -v $(pwd)/manticore.conf:/etc/manticoresearch/manticore.conf -v $(pwd)/data:/var/lib/manticore/ -p 127.0.0.1:9306:9306 -p 127.0.0.1:9308:9308 -d manticoresearch/manticoreMake sure to remove 127.0.0.1: if you want the ports to
be available for external hosts.
In many cases you might want to use Manticore together with other images specified in a docker-compose YAML file. Here is the minimal recommended specification for Manticore Search in docker-compose.yml:
version: '2.2'
services:
manticore:
container_name: manticore
image: manticoresearch/manticore
restart: always
ports:
- 127.0.0.1:9306:9306
- 127.0.0.1:9308:9308
ulimits:
nproc: 65535
nofile:
soft: 65535
hard: 65535
memlock:
soft: -1
hard: -1
volumes:
- ./data:/var/lib/manticore
# - ./manticore.conf:/etc/manticoresearch/manticore.conf # uncomment if you use a custom configBesides using the exposed ports 9306 and 9308 you can log into the
instance by running docker-compose exec manticore
mysql.
HTTP protocol is exposed on port 9308. You can map the port locally and connect with curl:
docker run --name manticore -p 9308:9308 -d manticoresearch/manticoreCreate a table:
POST /cli -d 'CREATE TABLE testrt ( title text, content text, gid integer)'Insert a document:
POST /insert
-d'{"index":"testrt","id":1,"doc":{"title":"Hello","content":"world","gid":1}}'Perform a simple search:
POST /search -d '{"index":"testrt","query":{"match":{"*":"hello world"}}}'By default, the server is set to send it’s logging to
/dev/stdout, which can be viewed from the host with:
docker logs manticoreThe query log can be diverted to Docker log by passing variable
QUERY_LOG_TO_STDOUT=true.
Here is a simple docker-compose.yml for defining a two
node cluster:
version: '2.2'
services:
manticore-1:
image: manticoresearch/manticore
restart: always
ulimits:
nproc: 65535
nofile:
soft: 65535
hard: 65535
memlock:
soft: -1
hard: -1
networks:
- manticore
manticore-2:
image: manticoresearch/manticore
restart: always
ulimits:
nproc: 65535
nofile:
soft: 65535
hard: 65535
memlock:
soft: -1
hard: -1
networks:
- manticore
networks:
manticore:
driver: bridgeStart it: docker-compose up
Create a cluster:
$ docker-compose exec manticore-1 mysql
mysql> CREATE TABLE testrt ( title text, content text, gid integer);
mysql> CREATE CLUSTER posts;
Query OK, 0 rows affected (0.24 sec)
mysql> ALTER CLUSTER posts ADD testrt;
Query OK, 0 rows affected (0.07 sec)
MySQL [(none)]> exit
ByeJoin to the the cluster on the 2nd instance
$ docker-compose exec manticore-2 mysql
mysql> JOIN CLUSTER posts AT 'manticore-1:9312';
mysql> INSERT INTO posts:testrt(title,content,gid) VALUES('hello','world',1);
Query OK, 1 row affected (0.00 sec)
MySQL [(none)]> exit
ByeIf you now go back to the first instance you’ll see the new record:
$ docker-compose exec manticore-1 mysql
MySQL [(none)]> select * from testrt;
+---------------------+------+-------+---------+
| id | gid | title | content |
+---------------------+------+-------+---------+
| 3891565839006040065 | 1 | hello | world |
+---------------------+------+-------+---------+
1 row in set (0.00 sec)
MySQL [(none)]> exit
ByeIt’s recommended to overwrite the default ulimits of docker for the Manticore instance:
--ulimit nofile=65536:65536For best performance, index components can be mlocked into memory. When Manticore is run under Docker, the instance requires additional privileges to allow memory locking. The following options must be added when running the instance:
--cap-add=IPC_LOCK --ulimit memlock=-1:-1If you want to run Manticore with your custom config containing indexes definition you will need to mount the configuration to the instance:
docker run --name manticore -v $(pwd)/manticore.conf:/etc/manticoresearch/manticore.conf -v $(pwd)/data/:/var/lib/manticore -p 127.0.0.1:9306:9306 -d manticoresearch/manticoreTake into account that Manticore search inside the container is run
under user manticore. Performing operations with index
files (like creating or rotating plain indexes) should be also done
under manticore. Otherwise the files will be created under
root and the search daemon won’t have rights to open them.
For example here is how you can rotate all indexes:
docker exec -it manticore gosu manticore indexer --all --rotateYou can also set individual searchd and
common configuration settings using Docker environment
variables.
The settings must be prefixed with their section name, example for in
case of mysql_version_string the variable must be named
searchd_mysql_version_string:
docker run --name manticore -p 127.0.0.1:9306:9306 -e searchd_mysql_version_string='5.5.0' -d manticoresearch/manticoreIn case of listen directive, you can pass using Docker
variable searchd_listen new listening interfaces in
addition to the default ones. Multiple interfaces can be declared
separated by semi-colon (“|”). For listening only on network address,
the $ip (retrieved internally from hostname
-i) can be used as address alias.
For example -e
searchd_listen='9316:http|9307:mysql|$ip:5443:mysql_vip' will add
an additional SQL interface on port 9307, an SQL VIP listener on port
5443 running only on the instance’s IP and an HTTP listener on port
9316, beside the defaults on 9306 and 9308, respectively.
$ docker run --rm -p 1188:9307 -e searchd_mysql_version_string='5.5.0' -e searchd_listen='9316:http|9307:mysql|$ip:5443:mysql_vip' manticore
[Mon Aug 17 07:31:58.719 2020] [1] using config file '/etc/manticoresearch/manticore.conf' (9130 chars)...
listening on all interfaces for http, port=9316
listening on all interfaces for mysql, port=9307
listening on 172.17.0.17:5443 for VIP mysql
listening on all interfaces for mysql, port=9306
listening on UNIX socket /var/run/mysqld/mysqld.sock
listening on 172.17.0.17:9312 for sphinx
listening on all interfaces for http, port=9308
prereading 0 indexes
prereaded 0 indexes in 0.000 sec
accepting connections