Database & Messaging

Redis

In-memory data store for caching and sessions

🐧 Linux🍎 Mac🪟 Windows📋 Quick reference →
Reviewed: Tested on: Kubernetes 1.29 · Terraform 1.8 · Ubuntu 22.04

What is this?

Redis stores data in memory for extremely fast reads — ideal for caching and session storage.

📁

Config files for Redis

Where to create or edit the main configuration — paths below match the setup steps.

  • /etc/redis/redis.conf

    Location: Redis server

    Bind, persistence, memory, auth

📥

Step 01

Install Redis

(01)Install

Linux
1sudo apt-get install -y redis-server
2sudo systemctl enable redis-server
⚙️

Step 02

Configure Redis

(01)Basic config

Linux
1sudo nano /etc/redis/redis.conf
2# bind 127.0.0.1
3# requirepass yourpassword
4sudo systemctl restart redis-server
5redis-cli ping # PONG

Step 03

Verify

(01)Test

Linux
1redis-cli set test hello
2redis-cli get test

Step 04

Manage

(01)Info

Linux
1redis-cli info memory
2redis-cli monitor

📋Config templates

3 YAML templates for Redis. Copy and deploy after setup.

3 ready-to-copy templates. Expand one, copy the YAML, then run the deploy commands.

docker-compose.yaml

PostgreSQL database + Flask app with env file and volume persistence

yaml
1version: "3.9"
2
3services:
4 db:
5 image: postgres:15-alpine
6 environment:
7 POSTGRES_DB: dukaan_db
8 POSTGRES_USER: dukaan
9 POSTGRES_PASSWORD: dukaan123
10 ports:
11 - "5432:5432"
12 volumes:
13 - pgdata:/var/lib/postgresql/data
14
15 app:
16 build: .
17 ports:
18 - "5000:5000"
19 env_file:
20 - .env
21 depends_on:
22 - db
23
24volumes:
25 pgdata:

Dockerfile

Flask application container image

dockerfile
1FROM python:3.12-slim
2WORKDIR /app
3COPY requirements.txt .
4RUN pip install --no-cache-dir -r requirements.txt
5COPY . .
6EXPOSE 5000
7CMD ["python", "app.py"]
📄

Step 01

Run with Docker Compose

(01)Build and start services

Linux
1cd your-project/
2docker compose up -d --build
3docker compose ps
4docker compose logs -f app

(02)Stop and clean up

Linux
1docker compose down
2docker compose down -v # remove volumes