Home > Net >  How to restart Weaviate in Docker without loosing my schema?
How to restart Weaviate in Docker without loosing my schema?

Time:12-04

I spun up weaviate using the docker image and then created two classes and added around 400 data entries for these classes using a Java client. I also tried the Q&A module for querying the data and it was working ok.

As soon as I restarted the Weaviate instance in the Docker container, my schema is was lost.

I am completely new to Weaviate and not sure what went wrong.

CodePudding user response:

That's because the Weaviate volume sits inside your container. Mounting a container will solve your problem. In the example below, change /var/weaviate to any folder you like).

For example:

---
version: '3.4'
services:
  weaviate:
    command:
    - --host
    - 0.0.0.0
    - --port
    - '8080'
    - --scheme
    - http
    image: semitechnologies/weaviate:1.8.0
    ports:
    - 8080:8080
    restart: on-failure:0
    volumes:
      - /var/weaviate:/var/lib/weaviate # <== set a volume here
    environment:
      QUERY_DEFAULTS_LIMIT: 25
      AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
      PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
      DEFAULT_VECTORIZER_MODULE: 'none'
      ENABLE_MODULES: ''
      CLUSTER_HOSTNAME: 'node1' # <== this can be set to an arbitrary name
...

CodePudding user response:

Docker itself is all temporary by default, That's part of the point of docker low footprint low clean up.

You can use volumes to create and map to a volume that is a shared folder with the host machine that will stay and remount between instances of the container.

Full documentation is here.

https://docs.docker.com/compose/compose-file/compose-file-v3/#volume-configuration-reference

TLDR;

A volumes, section to the compose file. That would look something like this:

services:
  weaviate:
    image: waviate
    volumes:
      - localFolder:/var/lib/weaviate/data
  • Related