{"name":"docker-compose-redis","title":"Docker Compose Redis","description":"A Docker Compose file for Redis with a password, persistence, a memory limit and a health check, plus variants with an app service and Redis Insight.","category":"deploy","updated":"2026-11-30","url":"https://sniptide.com/templates/docker-compose-redis","files":[{"name":"compose.yaml","language":"yaml","content":"services:\n  redis:\n    image: redis:8-alpine\n    restart: unless-stopped\n    command:\n      - redis-server\n      - --requirepass\n      - ${REDIS_PASSWORD:-dev}\n      - --appendonly\n      - \"yes\"\n      - --maxmemory\n      - 256mb\n      - --maxmemory-policy\n      - allkeys-lru\n    environment:\n      # redis-cli reads the password from this variable, so the health check can authenticate.\n      REDISCLI_AUTH: ${REDIS_PASSWORD:-dev}\n    ports:\n      - \"127.0.0.1:6379:6379\"\n    volumes:\n      - redis-data:/data\n    healthcheck:\n      test: [\"CMD\", \"redis-cli\", \"ping\"]\n      interval: 5s\n      timeout: 3s\n      retries: 10\n\nvolumes:\n  redis-data:\n"}]}