👤
Novice Handbook
  • Novice Handbook
  • Guide
  • Internet และ Web
    • HTML
  • Computer Language
    • Basic Computer Language (LV.1)
    • C Language (LV.1)
    • Python3 (LV.1)
  • Operating System
    • Linux
      • Basic Linux (LV.1)
  • TOOLS
    • Text Editor
      • Vim Editor
    • Source Control
      • GitLab
        • GitLab for small site (LV.1)
    • Container
      • Docker
        • Docker (LV.1)
        • Docker (LV.2)
      • Kubernetes
        • Kubernetes Intro (LV.0)
        • Kubernetes Basic (LV.1)
        • Kubernetes Intermediate (LV.2)
        • Helm (LV.2)
        • RKE2 (LV.3)
        • K3S (LV.3)
        • K3D (LV.3)
    • Repository
      • Harbor
        • Harbor for small site (LV.1)
        • Harbor for enterprise (LV.2)
    • Database
      • Redis
        • Redis on Docker Compose (LV.1)
        • Redis on Kubernetes (LV.2)
      • Elastic Stack
        • Elasticsearch & Kibana for small site (LV.1)
    • Observability
      • Prometheus
        • Prometheus for small site (LV.1)
        • Prometheus Operator (LV.2)
    • Security
      • Certbot (LV.1)
      • Falco
      • Hashicorp Vault
    • Collaboration
      • Nextcloud
Powered by GitBook
On this page

Was this helpful?

  1. TOOLS
  2. Database
  3. Redis

Redis on Docker Compose (LV.1)

ใน session นี้เราจะสร้าง standalone redis โดยใช้ image จาก bitnami เนื่องจาก image ของ bitnami มีการ custom entrypoint script ไว้เยอะ จึงช่วยให้ใช้งานผ่านการ set ENV ต่างๆได้ง่ายกกว่าการใช้ redis image จากของ official โดยตรง

ทำการสร้างไฟล์ docker-compose.yml โดยมี content ดังนี้

services:
  redis:
    image: bitnami/redis:7.4
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
    volumes:
      - redis-data:/bitnami/redis/data
    ports:
      - 6379:6379
  redis-exporter:
    image: oliver006/redis_exporter
    environment:
      - REDIS_ADDR=redis://redis:6379
    ports:
      - 9121:9121
volumes:
  redis-data:
services:
  redis:
    image: bitnami/redis:7.4
    environment:
      - REDIS_PASSWORD=mysecret
    volumes:
      - redis-data:/bitnami/redis/data
    ports:
      - 6379:6379
  redis-exporter:
    image: oliver006/redis_exporter
    environment:
      - REDIS_ADDR=redis://redis:6379
      - REDIS_PASSWORD=mysecret
    ports:
      - 9121:9121
volumes:
  redis-data:

deploy ด้วยการสั่ง compose up

docker compose up -d

จากตัวอย่างจะมีการ deploy redis exporter ด้วย เพื่อให้ tools observability มาอ่านข้อมูลสถานะของ redis ไปได้

PreviousRedisNextRedis on Kubernetes (LV.2)

Last updated 6 months ago

Was this helpful?