title | description |
---|---|
Using Meilisearch with Docker — Meilisearch documentation |
Learn how to use Docker to download and run Meilisearch, configure its behavior, and manage your Meilisearch data. |
In this guide you will learn how to use Docker to download and run Meilisearch, configure its behavior, and manage your Meilisearch data.
Docker is a tool that bundles applications into containers. Docker containers ensure your application runs the same way in different environments. When using Docker for development, we recommend following the official instructions to install Docker Desktop.
Docker containers are distributed in images. To use Meilisearch, use the docker pull
command to download a Meilisearch image:
docker pull getmeili/meilisearch:v1.14
Meilisearch deploys a new Docker image with every release of the engine. Each image is tagged with the corresponding Meilisearch version, indicated in the above example by the text following the :
symbol. You can see the full list of available Meilisearch Docker images on Docker Hub.
After completing the previous step, use docker run
to launch the Meilisearch image:
docker run -it --rm \
-p 7700:7700 \
-v $(pwd)/meili_data:/meili_data \
getmeili/meilisearch:v1.14
Meilisearch accepts a number of instance options during launch. You can configure these in two ways: environment variables and CLI arguments. Note that some options are only available as CLI arguments—consult our configuration reference for more details.
To pass environment variables to Docker, add the -e
argument to docker run
. The example below launches Meilisearch with a master key:
docker run -it --rm \
-p 7700:7700 \
-e MEILI_MASTER_KEY='MASTER_KEY'\
-v $(pwd)/meili_data:/meili_data \
getmeili/meilisearch:v1.14
If you want to pass command-line arguments to Meilisearch with Docker, you must add a line to the end of your docker run
command explicitly launching the meilisearch
binary:
docker run -it --rm \
-p 7700:7700 \
-v $(pwd)/meili_data:/meili_data \
getmeili/meilisearch:v1.14 \
meilisearch --master-key="MASTER_KEY"
When using Docker, your working directory is /meili_data
. This means the location of your database file is /meili_data/data.ms
.
By default, data written to a Docker container is deleted every time the container stops running. This data includes your indexes and the documents they store.
To keep your data intact between reboots, specify a dedicated volume by running Docker with the -v
command-line option:
docker run -it --rm \
-p 7700:7700 \
-v $(pwd)/meili_data:/meili_data \
getmeili/meilisearch:v1.14
The example above uses $(pwd)/meili_data
, which is a directory in the host machine. Depending on your OS, mounting volumes from the host to the container might result in performance loss and is only recommended when developing your application.
To export a dump, use the create dump endpoint as described in our dumps guide. Once the task is complete, you can access the dump file in /meili_data/dumps
inside the volume you passed with -v
.
To import a dump, use Meilisearch's --import-dump
command-line option and specify the path to the dump file. Make sure the path points to a volume reachable by Docker:
docker run -it --rm \
-p 7700:7700 \
-v $(pwd)/meili_data:/meili_data \
getmeili/meilisearch:v1.14 \
meilisearch --import-dump /meili_data/dumps/20200813-042312213.dump
Note that exporting and importing dumps require using command-line arguments. For more information on how to run Meilisearch with CLI options and Docker, refer to this guide's relevant section.
If you are storing your data in a persistent volume as instructed in [the data persistency section](#data-persistency), you must delete `/meili_data/data.ms` in that volume before importing a dump.Use dumps to migrate data between different Meilisearch releases. Read more about updating Meilisearch in our dedicated guide.
To generate a Meilisearch snapshot with Docker, launch Meilisearch with --schedule-snapshot
and --snapshot-dir
:
docker run -it --rm \
-p 7700:7700 \
-v $(pwd)/meili_data:/meili_data \
getmeili/meilisearch:v1.14 \
meilisearch --schedule-snapshot --snapshot-dir /meili_data/snapshots
--snapshot-dir
should point to a folder inside the Docker working directory for Meilisearch, /meili_data
. Once generated, snapshots will be available in the configured directory.
To import a snapshot, launch Meilisearch with the --import-snapshot
option:
docker run -it --rm \
-p 7700:7700 \
-v $(pwd)/meili_data:/meili_data \
getmeili/meilisearch:v1.14 \
meilisearch --import-snapshot /meili_data/snapshots/data.ms.snapshot
Use snapshots for backup or when migrating data between two Meilisearch instances of the same version. Read more about snapshots in our guide.