0

I'm creating an app which uses Weaviate locally. I have added created a docker-compose.yml file and ran docker-compose up in terminal to start the weaviate database. I have created a schema and added some data to my database and everything works fine. However, when I clone the code to another computer, the app crashes and it seems that the whole database schema and added data are gone. I'm new to docker and weaviate and don't know how to solve this problem. I would appreciate if any one can help me. My docker-compose.yml file was like this:

---
version: '3.4'
services:
  weaviate:
    command:
    - --host
    - 0.0.0.0
    - --port
    - '8080'
    - --scheme
    - http
    image: semitechnologies/weaviate:1.18.0
    volumes:
      - /var/weaviate:/var/lib/weaviate
    ports:
    - 8080:8080
    restart: on-failure:0
    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'
...

I have searched a little and changed my volumes like shown below. But didn't help.

---
version: '3.4'
services:
  weaviate:
    command:
    - --host
    - 0.0.0.0
    - --port
    - '8080'
    - --scheme
    - http
    image: semitechnologies/weaviate:1.18.0
    volumes:
      - weaviate-data:/data
    ports:
    - 8080:8080
    restart: on-failure:0
    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'
volumes:
  weaviate-data:
...
kheirq
  • 31
  • 2

1 Answers1

0

Your docker compose file shows that weaviate will store its data in /var/lib/weaviate INSIDE the container.

So, when you remove the container, the data will be gone.

The solution is to mount /var/lib/weaviate somewhere in your filesystem.

Since you are new to docker, I suggest starting with this doc to get familiar with the concept of mounting volumes and then refer to the docker compose official docs on how to mount volumes in a docker-compose.yaml.

hsm207
  • 471
  • 2
  • 4