> For the complete documentation index, see [llms.txt](https://notes.joeir.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.joeir.net/application-infrastructure/databases/redis.md).

# Redis

## Reference Links

## Configuration

The following configuration is a production-ready `.conf` file which:

1. Binds to 0.0.0.0
2. Disables `default` user
3. Forces use of a password
4. Prevents users from running configuration commands
5. Creates a app user named `user` with password `password` (**change this according to the comments in the file**)

```properties
# security configurations as documented at https://redis.io/topics/security
bind 0.0.0.0
rename-command CONFIG ""

# disable default user
requirepass password
user default off -@all

# setup app user
# to generate the password, run `printf -- 'password' | sha256sum | cut -f 1 -d ' '`
# the following password (after the '#' character) is the sha256 of "password" without the quotes
user user on ~* +ping +client +@read +@write +@set +@list #5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8
```

## Docker

### Image

{% embed url="<https://hub.docker.com/_/redis>" %}

### Compose

```yaml
version: "3.7"
services:
  redis: # access with `redis-cli -h 127.0.0.1 -p 6379` and use `auth user password` in the redis tty
    # image reference: https://hub.docker.com/_/redis
    image: library/redis:7.0.12-alpine
    command:
      - redis-server
      - /usr/local/etc/redis/redis.conf
    ports: ["6379:6379"]
    network_mode: host
    volumes: # [] # uncomment and comment below to remove persistence
      - ./.data/redis/config/redis.conf:/usr/local/etc/redis/redis.conf
      - ./.data/redis/data:/data
```
