redis-stack / redis-stack-docs

6 stars 55 forks source link

Why JSON is not working in Redis Stack? #235

Open vic-951 opened 7 months ago

vic-951 commented 7 months ago

Hello there,

I started a docker container with redis-stack and tried to insert JSON keys but redisinsight tell me: RedisJSON is not available for this database

JSON.SET school_json:4 $ '{"name":"Forest School","description":"The philosophy behind Forest School is based upon the desire to provide young children with an education that encourages appreciation of the wide world in nature while achieving independence, confidence and high self-esteem. ","class":"independent","type":["forest","montessori","democratic"],"address":{"city":"Oxford","street":"Trident Street"},"students":1200,"location":"51.781756, -1.123196","status_log":["new","operating"]}'

image

this is my docker compose file

version: '3'

services:
  redis:
    image: redis/redis-stack-server:latest
    restart: always
    container_name: rds
    command: redis-server /usr/local/etc/redis/redis.conf
    ports:
      - "7001:6379"
    volumes:
      - /home/user/docker/redis/data:/data
      - /home/user/docker/redis/conf/redis.conf:/usr/local/etc/redis/redis.conf

how can I activate RedisJSON in docker?

vic-951 commented 7 months ago

I got the solution from Discord. The command is the problem, because of this all modules where not loaded (see https://github.com/redis-stack/redis-stack/blob/master/etc/scripts/entrypoint.sh)

so the solution is to delete the command and set the root path for redis-stack.conf

version: '3'

services:
  redis:
    image: redis/redis-stack-server:latest
    restart: always
    container_name: rds
    ports:
      - "7001:6379"
    volumes:
      - /home/user/docker/redis/data:/data
      - /home/user/docker/redis/conf/redis.conf:/redis-stack.conf