meilisearch: Using Docker, Meilisearch v0.24 does not write data in /data.ms anymore

Describe the bug Following the docs in Getting Started / Installation / Download and launch / Docker, it says that Meilisearch write data in /data.ms. When new user try it with Docker using persistence volume, they will use -v $(pwd)/data.ms:/data.ms. But looking inside the folder, they will find no data.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://docs.meilisearch.com/learn/getting_started/installation.html#download-and-launch
  2. Click on ‘Docker’ tab
  3. Copy/Paste the command to start using meilisearch
  4. Check your $(pwd)/data.ms folder on your host machine
  5. No data is persist

Expected behavior Data appears in the right folder of the host machine

MeiliSearch version: v0.24

Additional context When changing user https://github.com/meilisearch/MeiliSearch/issues/1757 the workspace dir has also changed. It is no more /data.ms but /home/meili/data.ms

We could update the documentation or remove the WORDIR ${HOME} and let it be in /data.ms

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 46 (25 by maintainers)

Commits related to this issue

Most upvoted comments

On Debian 11 Server with Docker version 20.10.11, build dea9396

As a non-root user logged in to the server,

1. With meilisearch:latest aka v0.24.0 (/home/meili/data.ms)

docker run -it --rm \
    -p 7700:7700 \
    -v $(pwd)/data.ms:/home/meili/data.ms \
    getmeili/meilisearch:latest

Got

Error: An internal error has occurred. `Permission denied (os error 13)`.

2. With meilisearch:latest aka v0.23.0 (/data.ms)

docker run -it --rm \
    -p 7700:7700 \
    -v $(pwd)/data.ms:/data.ms \
    getmeili/meilisearch:v0.23.0

Works!

3. As @sanders41 mentionned (using -u root or -u 0:0) for v0.24.0

docker run -it --rm \
    -p 7700:7700 \
    -u 0:0 \
    -v $(pwd)/data.ms:/home/meili/data.ms \
    getmeili/meilisearch:latest

Works!

4. Chown mounted folder to 1000:1000

mkdir -p $(pwd)/data.ms
chown -R 1000:1000 $(pwd)/data.ms
docker run -it --rm \
    -p 7700:7700 \
    -v $(pwd)/data.ms:/home/meili/data.ms \
    getmeili/meilisearch:latest

Works!

5. Using -u 1000:1000 (because meili user inside has uid=1000, gid=1000)

docker run -it --rm \
    -p 7700:7700 \
    -u 1000:1000 \
    -v $(pwd)/data.ms:/home/meili/data.ms \
    getmeili/meilisearch:latest

Got

Error: An internal error has occurred. `Permission denied (os error 13)`.

For v0.24.0 (meili user), case 3 and 4 work with extra

Hi, @michaelbaudino thanks, I tried your solution and it works. However, I find it a bit patchy, and doesn’t seem to be a “clean” fix of our issue. 😞

But, I found a pretty long discussion about workarounds or features to fix this. There are:

  • “chown scripts” like yours
  • make the user give the ownership of the destination volume to (uid:gid) 1000:1000
  • using named volumes which, I think, is a relatively “clean” workaround for development. ⚖️

Now @ all! (@michaelbaudino, @K2ouMais, @caugner, @sanders41, @sovanna, @FLevent29). Is your issue:

  • a development issue? 👍 (where named volumes could work to fix this issue)
docker run -it --rm \
    -p 7700:7700 \
-    -v $(pwd)/data.ms:/home/meili/data.ms \
+    -v meilisearch_db:/home/meili/data.ms \
    getmeili/meilisearch:latest
  • a production issue? 👎 (where named volumes can’t be a fix of this issue)

warning ⚠️

the current getmeili/meilisearch:latest doesn’t work with named volume too, but I can easily patch it to make it work.

if you want to try named volumes, use this dummy Dockerfile:

FROM    alpine:3.14

RUN adduser -D meili

# pre-create inner volume and make meili own it.
RUN mkdir -p /home/meili/data.ms && \
    chown meili /home/meili/data.ms

USER meili

# try to create a file in the volume, this should not throw an error with named volumes.
CMD     ["touch", "/home/meili/data.ms/database"]

build: docker build -t dummy_meili .

run: docker run -it --rm -v meilisearch_db:/home/meili/data.ms dummy_meili:latest

Don’t hesitate to give me more feedbacks about this! 🙏

Hum, regarding the error you have and also since the core-team does not have time to make the dockerfile works with a meili user, I think we have to roll back this change introduced in v0.24.0. I’ll let you know, but this problem will be fixed in v0.25.0.

Thanks for your investigation @sanders41 and @sovanna. Also, sorry for this issue.

@ManyTheFish for me it is currently development, but the plan is to move the same setup to production once things are ready.

Hey all! I’m currently trying to fix this, but, because it’s not a trivial fix, we will revert the PR that introduces this bug for the v0.25 and rewrite a new Dockerfile in another PR for v0.26.

Thanks for your feedbacks! 🙌

@FLevent29 if it is easier you can uses your docker-compose.yaml file for this instead of a separate Dockerfile.

version: "3.1"
services:
  meilisearch:
    image: getmeili/meilisearch:v0.24.0
    user: root
    ports:
      - "7700:7700"
    volumes:
      - "meili:/home/meili/data.ms"
    environment:
      MEILI_MASTER_KEY: "masterKey"
volumes:
  meili:

As a side note, you probably want to read your MEILI_MASTER_KEY from an environment variable rather than hard coding it in MEILI_MASTER_KEY: "masterKey" because if you commit it to your repository people will be able to see it.

Hello @sovanna, thank you so much for this report! 🙏 sorry for the breaking change we did not anticipate enough regarding the docs!

I will create a PR to update the documentation today 😃

Also, I opened a more general discussion about the data.ms path: https://github.com/meilisearch/product/discussions/332

I will close the issue once it’s fixed in the docs.