Cheat Sheets

Run Redis in Podman or Docker + redis-cli Cheat Sheet (PDF)

Redis in a container answered 21,400 SET requests per second through Docker’s published loopback port on a 2 vCPU test box. Rootless Podman’s port reached 25,200, and the benchmark inside the container reached 44,800. Going through the port costs half the throughput, yet it is rarely what breaks a fresh docker run redis or podman run redis. Three things do: a password passed with -a that lands in shell history, a Podman volume that SELinux refuses on Rocky Linux, and a persistence setup nobody checked before the first restart.

Original content from computingforgeeks.com - post 114720

This guide runs Redis under Docker and rootless Podman (the redis:8.10.3 image, tested in November 2026 on Ubuntu 26.04 and Rocky Linux 10). It then works through the redis-cli commands you use every day, from SCAN instead of KEYS and TTLs to hashes, lists and sets, the slow log, big key scans, persistence checks and a least-privilege ACL user. The cheat sheet tables come first, and the numbered steps after them show how each command behaved on the test boxes.

redis-cli Cheat Sheet (Quick Reference)

Every row below ran against the redis:8.10.3 container built in the steps further down. The tables assume the two-line shell setup from Step 6: REDISCLI_AUTH holds the password and redis-cli is an alias for docker exec -i -e REDISCLI_AUTH redis redis-cli (swap docker for podman on Rocky). Because the client runs without a TTY inside the container, replies come back in raw mode, so you see 3 rather than (integer) 3.

Connect and authenticate

CommandWhat it does
export REDISCLI_AUTH="$(cat ~/redis-lab/default.pass)"Give redis-cli the password without putting it in argv
redis-cli PINGHealth check; PONG means connected and authenticated
redis-cli -h 127.0.0.1 -p 6379 PINGConnect to a given host and port
REDISCLI_AUTH="$(cat ~/redis-lab/app.pass)" redis-cli --user app GET app:visitsAuthenticate as an ACL user for one command
redis-cli --user app --askpass GET app:visits < ~/redis-lab/app.passRead the password from stdin instead of the environment
redis-cli -n 1 DBSIZERun a command against database 1

Server info and runtime config

CommandWhat it does
redis-cli INFO serverVersion, mode, OS, uptime
redis-cli INFO memoryUsed memory, RSS, fragmentation, eviction policy
redis-cli INFO persistenceRDB and AOF status, last save result
redis-cli CONFIG GET 'maxmemory*'Read settings by glob pattern
redis-cli CONFIG SET maxmemory 256mbChange a setting live (lost on restart)
redis-cli CONFIG SET maxmemory-policy allkeys-lruEvict least recently used keys at the memory cap
redis-cli DBSIZENumber of keys in the current database
redis-cli CLIENT LISTEvery connected client with its flags

Find and inspect keys

CommandWhat it does
redis-cli --scan --pattern 'user:9999*'Iterate matching keys without blocking the server
redis-cli SCAN 0 MATCH 'user:*' COUNT 1000One SCAN page; first line is the next cursor
redis-cli KEYS 'user:*'Match every key in one blocking call (avoid in production)
redis-cli TYPE profile:1001Data type of a key
redis-cli OBJECT ENCODING profile:1001Internal encoding (listpack, hashtable…)
redis-cli MEMORY USAGE profile:1001Bytes one key uses, overhead included
redis-cli EXISTS profile:10011 if the key exists, 0 if not
redis-cli UNLINK big:listDelete a key, freeing memory in the background

Strings, counters, expiry and locks

CommandWhat it does
redis-cli SET session:42 token-abc EX 300Set a value that expires in 300 seconds
redis-cli GET lock:job1Read a string value (empty line if missing)
redis-cli TTL session:42Seconds left; -1 no expiry, -2 no such key
redis-cli EXPIRE session:42 60Set or replace a key’s expiry
redis-cli PERSIST session:42Remove the expiry
redis-cli SET lock:job1 worker-a NX EX 30Take a lock only if nobody holds it
redis-cli INCR counter:hitsAtomic counter, creates the key at 0

Hashes, lists and sets

CommandWhat it does
redis-cli HSET profile:1001 name ada plan pro logins 0Set fields in a hash
redis-cli HGET profile:1001 planRead one field
redis-cli HGETALL profile:1001All fields and values, alternating lines
redis-cli HINCRBY profile:1001 logins 1Increment a numeric field
redis-cli RPUSH queue:emails job1 job2Append to a list (queue tail)
redis-cli LPOP queue:emailsTake from the head of a list
redis-cli LRANGE queue:emails 0 -1Print the whole list
redis-cli BLPOP queue:empty 2Wait up to 2 seconds for an item
redis-cli SADD tags:post1 redis dockerAdd members to a set
redis-cli SISMEMBER tags:post1 docker1 if the member is in the set
redis-cli SINTER tags:post1 tags:post2Members common to both sets

Debug latency, slow commands and big keys

CommandWhat it does
redis-cli SLOWLOG GET 2Last 2 commands slower than the threshold
redis-cli CONFIG SET slowlog-log-slower-than 1000Log commands over 1 ms (default 10000 Β΅s)
redis-cli SLOWLOG RESETEmpty the slow log
redis-cli --bigkeysLargest key per type, by element count
redis-cli --memkeysLargest key per type, by bytes
redis-cli --keystatsKey size percentiles and per-type totals
redis-cli --intrinsic-latency 5Host scheduling latency over 5 seconds
redis-cli --latencyRound-trip latency; one 1 s sample without a TTY
docker exec -e REDISCLI_AUTH redis timeout 3 redis-cli MONITORWatch every command for 3 s, then exit

Persistence and ACL users

CommandWhat it does
redis-cli BGSAVEWrite an RDB snapshot in the background
redis-cli LASTSAVEUnix time of the last successful save
redis-cli ACL USERSList ACL users
redis-cli ACL DRYRUN app GET user:1Test a command against a user’s rules
redis-cli ACL LOG 1Most recent denied command, with the client
redis-cli ACL SETUSER app '+ping' '+echo'Grant single commands to a user (safer than a category)
redis-cli ACL GETUSER appShow a user’s flags, command rules and key patterns
seq 1 100000 | awk '{print "SET user:"$1" value-"$1}' | redis-cli --pipeBulk load 100,000 keys in one stream

The rest of this page shows how each group behaved on the test boxes, starting with the containers themselves. The outputs there are real captures, so you can compare your own results with ours.

Step 1: Install Docker or Podman

The tests used two e2-standard-2 cloud VMs (2 vCPU, 8 GB RAM): Ubuntu 26.04 with both engines from the Ubuntu archive, and Rocky Linux 10.2 with Podman from AppStream. Pick the tab for your host. You need only one engine, because the Redis steps are the same for both apart from the SELinux handling in Step 4. If you want Redis as a host service from the distro packages instead, follow the guides to install Redis on Ubuntu 26.04 or install Redis on Rocky Linux and AlmaLinux. The redis-cli tables on this page work the same against them.

sudo apt-get update && sudo apt-get install -y docker.io docker-compose-v2 podman
sudo usermod -aG docker $USER

Log out and back in after usermod so the docker group applies to your session. Membership of that group is root-equivalent on the host, so grant it only to admin accounts; the Docker cheat sheet and the Podman cheat sheet cover the engine commands this guide does not. Then confirm what got installed, because the two hosts ship different engine versions and every later output depends on them.

docker --version; docker compose version; podman --version

The Ubuntu archive packages Docker 29.1 with Compose 2.40 and Podman 5.7, so no third-party repository is needed on that host.

Docker version 29.1.3, build 29.1.3-0ubuntu4.1
Docker Compose version 2.40.3+ds1-0ubuntu1
podman version 5.7.0

Two notes from the test runs. On Ubuntu, rootless Podman containers stop when your SSH session ends unless lingering is on; our benchmark container on that host died at logout until we ran sudo loginctl enable-linger $USER, the same command Step 5 uses on Rocky. On Rocky, Docker CE from download.docker.com also installs fine (version 29.9.3 here), but its daemon runs with SELinux support off, and a host directory mounted without a label failed with Can't open or create append-only dir appendonlydir: Permission denied. The named-volume form from Step 3 started cleanly under Docker CE on the same Rocky box, so use a named volume there or stay with Podman.

Step 2: Keep the Redis password in a file

The official image starts with no password, which is fine only until someone publishes the port on 0.0.0.0. We set requirepass from a generated file instead of typing it, because a password typed after -a ends up in shell history and in the process list of the host. The same three commands run unchanged on Ubuntu and Rocky, so create a private directory and a 48-character random password. The directory permissions matter more than they look, because they are what protects the configuration file later in this step.

mkdir -p ~/redis-lab && chmod 700 ~/redis-lab
openssl rand -hex 24 > ~/redis-lab/default.pass && chmod 600 ~/redis-lab/default.pass

Write a minimal redis.conf that reads the password from that file and turns on the append-only file with a one-second fsync. That setting loses at most about a second of writes on a crash, so it suits a cache that also holds data you would rather keep.

printf 'requirepass %s\nappendonly yes\nappendfsync everysec\n' "$(cat ~/redis-lab/default.pass)" > ~/redis-lab/redis.conf

Check the permissions before mounting anything, because the container reads these files as a different user than the one who created them. We want the password file closed to everyone but its owner, and the next listing shows whether that held.

ls -l ~/redis-lab

The password file is owner-only, while redis.conf keeps the default 664 mode from the umask. That difference is deliberate, as the next paragraph explains.

total 8
-rw------- 1 klinsmann klinsmann 49 Nov 11 07:48 default.pass
-rw-rw-r-- 1 klinsmann klinsmann 97 Nov 11 07:48 redis.conf

That 664 on redis.conf looks loose, since the file now contains the password. It is acceptable here only because the parent directory is mode 700, so no other host user can reach the file. Redis inside the container runs as the redis user (UID 999), which reads the bind-mounted file through the “other” permission bits, so a stricter mode locks the server out. We tested a copy at mode 600 under Docker, and the container exited at once. The log said only that Redis could not read its configuration, which is a confusing message when the file plainly exists.

1:C 11 Nov 2026 08:03:59.578 # Fatal error, can't open config file '/usr/local/etc/redis/redis.conf': Permission denied

So tighten the directory, not the file, and keep the 664 mode on redis.conf. The 700 directory is what keeps other host users out, while the file mode only has to let UID 999 read it.

Step 3: Run Redis in a Docker container

Pin the image to a full version instead of redis:latest, so the next docker pull or container re-create never brings a new major under your data. The tag below was the newest stable release on the Redis releases page when we tested. It carries a fix for a cluster-bus heap overflow, so older 8.x tags are worth replacing.

time docker pull redis:8.10.3 # https://github.com/redis/redis/releases

The pull took 4.2 seconds on the test box. Check what landed on disk:

docker image ls redis

The image is 57.6 MB to download and 213 MB unpacked, because Redis 8 bundles the Search, JSON, time series and probabilistic modules that used to be Redis Stack. Those modules load at start, which is why the idle server later shows a high fragmentation ratio.

WARNING: This output is designed for human readability. For machine-readable output, please use --format.
IMAGE          ID            DISK USAGE   CONTENT SIZE   EXTRA
redis:8.10.3   1f88291b4c57        213MB         57.6MB        

Start the container with a named volume for /data, the config mounted read-only, and the port published on loopback only. Publishing on 127.0.0.1 keeps Docker from opening 6379 to the world through its own iptables rules, which bypass UFW, so the loopback address is a security setting and not a cosmetic one.

docker run -d --name redis --restart unless-stopped -p 127.0.0.1:6379:6379 -v redis-data:/data -v ~/redis-lab/redis.conf:/usr/local/etc/redis/redis.conf:ro redis:8.10.3 redis-server /usr/local/etc/redis/redis.conf

Confirm it is up and bound where you expect, because a container that started with the wrong address looks healthy until someone scans the host. We check the PORTS column first for that reason, since it is the quickest way to see the bound address.

docker ps --filter name=redis

The PORTS column must read 127.0.0.1:6379->6379/tcp. A bare 0.0.0.0:6379 here means the -p flag lost its address, so stop the container and fix the command before going on. Data loaded later would otherwise sit behind a port that every host on the network can reach.

CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS                      NAMES
4c27982ae0af   redis:8.10.3   "docker-entrypoint.s…"   6 seconds ago   Up 4 seconds   127.0.0.1:6379->6379/tcp   redis

The last log lines show that the config was read, because an AOF base file is created at start only when appendonly yes took effect. If those lines are missing, the file was not mounted where Redis looks for it. Fix the mount first, because every later persistence check depends on this setting.

docker logs redis 2>&1 | tail -n 6

Look for the two “Creating AOF” lines and “Ready to accept connections”. Together they show that Redis created its append-only files and is now listening. We treat that trio as the readiness check, because it proves the config, the volume and the server all came up.

1:M 11 Nov 2026 07:48:42.574 * <search> Acquired RedisJSON_V8 API
1:M 11 Nov 2026 07:48:42.575 * Server initialized
1:M 11 Nov 2026 07:48:42.575 * BGSAVE done, 0 keys saved, 0 keys skipped, 89 bytes written.
1:M 11 Nov 2026 07:48:42.578 * Creating AOF base file appendonly.aof.1.base.rdb on server start
1:M 11 Nov 2026 07:48:42.582 * Creating AOF incr file appendonly.aof.1.incr.aof on server start
1:M 11 Nov 2026 07:48:42.582 * Ready to accept connections tcp

A command without credentials is now refused, which is the result you want. Send a bare PING with no password to prove it. We run this check on every new container, because a server that answers without credentials would make every later security step pointless.

docker exec redis redis-cli PING

Redis answers with the authentication error instead of PONG, so the password from Step 2 is active and the port is not an open door. The failure is the expected result, which is why we count it as a pass for this test.

NOAUTH Authentication required.

In the terminal below, the same run on the Ubuntu 26.04 test box goes from the pinned pull to the refused unauthenticated PING.

Redis 8.10.3 Docker container started on Ubuntu 26.04 with a loopback port and NOAUTH on unauthenticated redis-cli PING

Everything from Step 6 onward talks to this container named redis, so keep it running while you work through the rest of the page.

Same container with Docker Compose

Compose is the better choice once Redis sits next to an application container, because the service definition lives in a file you can keep in Git. Create a project directory with its own copy of the config.

mkdir -p ~/redis-compose && chmod 700 ~/redis-compose && cp ~/redis-lab/redis.conf ~/redis-compose/redis.conf
vim ~/redis-compose/compose.yaml

Paste this service definition. It publishes on 6381 here only so it can run beside the first container, so use 6379 when it is the only one. The loopback address stays in place, because the compose file must not undo the protection from Step 3.

services:
  redis:
    image: redis:8.10.3
    container_name: redis-compose
    restart: unless-stopped
    command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
    ports:
      - "127.0.0.1:6381:6379"
    volumes:
      - redis-compose-data:/data
      - ./redis.conf:/usr/local/etc/redis/redis.conf:ro

volumes:
  redis-compose-data:

Bring it up from the project directory:

cd ~/redis-compose && docker compose up -d

Compose creates a project network, the named volume and the container. The separate network and volume mean this stack cannot touch the data of the first container.

 Network redis-compose_default  Creating
 Network redis-compose_default  Created
 Volume redis-compose_redis-compose-data  Creating
 Volume redis-compose_redis-compose-data  Created
 Container redis-compose  Creating
 Container redis-compose  Created
 Container redis-compose  Starting
 Container redis-compose  Started

Export the password into REDISCLI_AUTH first (Step 6 explains why), then count keys. The count proves the password from the copied config works in this container too, because an unauthenticated count would be refused. We count keys instead of sending a PING here, so the same command also shows whether the volume is empty.

export REDISCLI_AUTH="$(cat ~/redis-lab/default.pass)"
docker exec -e REDISCLI_AUTH redis-compose redis-cli DBSIZE

The new volume is empty, so the answer is 0. Tear the project down with docker compose down. The named volume survives that, and only docker compose down -v deletes it, so keep the -v for a real cleanup.

Step 4: Run Redis in rootless Podman with SELinux

This Redis Podman setup runs the same container as your normal user on Rocky Linux 10, with SELinux enforcing. Use the fully qualified image name so Podman never has to choose a registry for a short name. The pull took 5.3 seconds.

podman pull docker.io/library/redis:8.10.3 # https://github.com/redis/redis/releases

Run the Step 2 commands again on this host, and add a plain directory for the data, because a bind mount is what makes the SELinux label matter. A named volume would hide the problem we want to show next.

mkdir -p ~/redis-lab/data && chmod 700 ~/redis-lab

Start with the volume flags most Docker guides print, without a label option, to see the failure first. Seeing it once makes the symptom easy to recognise later. We ran it exactly as shown in many guides, because the quiet exit is the part that costs readers an hour.

podman run -d --name redis -p 127.0.0.1:6379:6379 -v ~/redis-lab/data:/data -v ~/redis-lab/redis.conf:/usr/local/etc/redis/redis.conf:ro docker.io/library/redis:8.10.3 redis-server /usr/local/etc/redis/redis.conf

Podman prints a container ID and returns 0, so the run looks fine. Four seconds later the container is gone, which means the failure happens inside the container and not at the podman run call.

podman ps -a --filter name=redis --format '{{.Names}} {{.Status}}'

Status 1 is the exit code. A non-zero exit this early points at the entrypoint, so the container log is the next place to look.

redis Exited (1) 4 seconds ago

The log holds a single line, and it does not mention SELinux at all. It comes from the entrypoint of the image, which walks /data to fix ownership before it starts Redis, so a denied read there stops the container before Redis ever runs.

podman logs redis 2>&1 | tail -n 5

Here is that single log line. It reports a permission error on . but never says that SELinux is the cause.

find: '.': Permission denied

On our box sudo ausearch -m avc -ts recent returned nothing for this denial, so the audit log is not the quickest way to diagnose it. The file labels are. Both paths still carry the home directory type, user_home_t, which a container process is not allowed to read, so listing the labels with ls -dZ settles the question in one command.

ls -dZ ~/redis-lab/data ~/redis-lab/redis.conf

Both report the home directory context. That is the cause of the failure, because the SELinux policy does not let a container process read user_home_t files. The Docker run in Step 3 needed no label on Ubuntu, so the same flags work there and fail here.

unconfined_u:object_r:user_home_t:s0 /home/klinsmann/redis-lab/data
unconfined_u:object_r:user_home_t:s0 /home/klinsmann/redis-lab/redis.conf

Remove the dead container with podman rm -f redis and run it again with :Z on both mounts. The two label options differ in who can reach the files afterwards.

  • Capital Z: relabels the content with a private label for this one container, so no other container can read it.
  • Lowercase :z: applies a shared label that every container can use, which you want only for data that several containers mount.

Redis data belongs to one container, so the private label is the right choice here.

podman run -d --name redis -p 127.0.0.1:6379:6379 -v ~/redis-lab/data:/data:Z -v ~/redis-lab/redis.conf:/usr/local/etc/redis/redis.conf:ro,Z docker.io/library/redis:8.10.3 redis-server /usr/local/etc/redis/redis.conf

Now the container stays up. Surviving the entrypoint check means the relabelled paths are readable from inside.

podman ps --filter name=redis --format '{{.Names}} {{.Status}} {{.Ports}}'

Status is Up with the loopback port, so the container is both running and bound only to the local host, as it was under Docker. We kept that binding on purpose, because the label fix has nothing to do with network exposure.

redis Up 4 seconds 127.0.0.1:6379->6379/tcp

Listing the labels again shows what :Z changed on the host, since the relabel happens on the files themselves and not inside the container. We compare the two listings side by side, because the change in the type column is the whole fix.

ls -dZ ~/redis-lab/data ~/redis-lab/redis.conf

The type is now container_file_t, and the MCS pair c332,c647 ties both paths to this container only. Another container with a different pair would be refused, which is the isolation the private label buys.

system_u:object_r:container_file_t:s0:c332,c647 /home/klinsmann/redis-lab/data
system_u:object_r:container_file_t:s0:c332,c647 /home/klinsmann/redis-lab/redis.conf

In the capture below, the failed run, the labels before and after, and the working container appear together, taken on the Rocky Linux 10 test box with SELinux enforcing.

Rootless Podman Redis container failing without :Z and running with :Z on Rocky Linux 10, SELinux labels before and after

Never point :Z at a system path such as /etc or your whole home directory. Podman relabels whatever you give it, and other confined services then lose access to those files.

Who owns the data files in rootless mode

Once you have written a key and run BGSAVE (Step 6 sets up the client), list the data directory from the host. The owner column holds a surprise for anyone used to Docker.

ls -ln ~/redis-lab/data

The files belong to UID 1180646, not to you, so ordinary host tools treat them as another user’s data. That is the first thing we noticed when we looked at the data directory, and it explains the backup advice below.

total 4
drwx------. 2 1180646 1180646 103 Nov 11 08:02 appendonlydir
-rw-------. 1 1180646 1180646 112 Nov 11 08:02 dump.rdb

That number is the redis user of the container (UID 999) mapped into your subordinate UID range. Read the same directory from inside your user namespace to see what the container sees.

podman unshare ls -ln ~/redis-lab/data

Inside the namespace the owner is 999 again, which confirms that nothing is wrong with the files and only the view from the host differs. We rely on that mapping for backups, because the namespace view is the one that matches what Redis itself sees.

total 4
drwx------. 2 999 999 103 Nov 11 08:02 appendonlydir
-rw-------. 1 999 999 112 Nov 11 08:02 dump.rdb

The practical consequence is backups. A host-side cp or tar of dump.rdb as your user fails on the 0600 file, so wrap it in podman unshare or copy it out with podman cp redis:/data/dump.rdb . instead.

Step 5: Start Redis at boot with a Quadlet unit

Docker’s --restart unless-stopped works because a root daemon starts at boot. Rootless Podman has no daemon, so systemd does that job through a Quadlet file, which replaces the old podman generate systemd output. Remove the manual container first with podman rm -f redis, because the unit would otherwise collide with the name and the port. Then create the unit directory and file.

mkdir -p ~/.config/containers/systemd
vim ~/.config/containers/systemd/redis.container

Paste the unit. The specifier %h expands to your home directory, and both volumes keep their :Z, so the labels from Step 4 carry over to the service. Without them the unit would fail the same way as the first run, because SELinux blocks the bind mounts again.

[Unit]
Description=Redis 8 in rootless Podman

[Container]
ContainerName=redis
Image=docker.io/library/redis:8.10.3
Exec=redis-server /usr/local/etc/redis/redis.conf
PublishPort=127.0.0.1:6379:6379
Volume=%h/redis-lab/data:/data:Z
Volume=%h/redis-lab/redis.conf:/usr/local/etc/redis/redis.conf:ro,Z

[Service]
Restart=always

[Install]
WantedBy=default.target

Before starting anything, ask the generator what it will produce. A typo in a key shows up here instead of as a silently missing service, so the dry run costs nothing and saves a debugging session. Read the generated file for the mounts and the port before you start the unit.

/usr/libexec/podman/quadlet -dryrun -user 2>&1 | head -n 25

The output is the generated redis.service, with a network-online dependency and podman rm stop hooks added for you. You did not write either of those, which is the point of using Quadlet over a hand-made unit.

quadlet-generator[8752]: Loading source unit file /home/klinsmann/.config/containers/systemd/redis.container
---redis.service---
[Unit]
Wants=podman-user-wait-network-online.service
After=podman-user-wait-network-online.service
Description=Redis 8 in rootless Podman
SourcePath=/home/klinsmann/.config/containers/systemd/redis.container
RequiresMountsFor=%t/containers

[X-Container]
ContainerName=redis
Image=docker.io/library/redis:8.10.3
Exec=redis-server /usr/local/etc/redis/redis.conf
PublishPort=127.0.0.1:6379:6379
Volume=%h/redis-lab/data:/data:Z
Volume=%h/redis-lab/redis.conf:/usr/local/etc/redis/redis.conf:ro,Z

[Service]
Restart=always
Environment=PODMAN_SYSTEMD_UNIT=%n
KillMode=mixed
ExecStop=/usr/bin/podman rm -v -f -i redis
ExecStopPost=-/usr/bin/podman rm -v -f -i redis
Delegate=yes
Type=notify

Enable lingering so your user’s systemd instance starts at boot without a login session, then load and start the service. Skip the linger step and Redis comes up only after you SSH in, so the unit would look fine in testing and fail after the first unattended reboot.

sudo loginctl enable-linger $USER
systemctl --user daemon-reload && systemctl --user start redis.service

Generated units cannot be enabled with systemctl --user enable, because the [Install] section in the .container file is what hooks it into default.target. Check the status to see that it took effect. A unit that shows as loaded but inactive usually means the install step was skipped.

systemctl --user status redis.service --no-pager | head -n 12

The unit is Active (running), with conmon as the main PID and Redis in the payload cgroup at 39.7 MB of memory. The small footprint is the server itself, because the dataset is still nearly empty at this point. We measured it right after the first start, so treat that figure as the floor and not as a sizing figure.

● redis.service - Redis 8 in rootless Podman
     Loaded: loaded (/home/klinsmann/.config/containers/systemd/redis.container; generated)
     Active: active (running) since Wed 2026-11-11 08:02:53 UTC; 3s ago
 Invocation: 1a0dc9ca1c3341f5b466c88cdc37c85e
   Main PID: 8862 (conmon)
      Tasks: 8 (limit: 48395)
     Memory: 39.7M (peak: 46.9M)
        CPU: 283ms
     CGroup: /user.slice/user-1010.slice/[email protected]/app.slice/redis.service
             β”œβ”€libpod-payload-cae8a5a48306f156eb9f5fea6ffff51cbbad20b19cce8e264ae349499a1d251d
             β”‚ └─8864 "redis-server *:6379"
             └─runtime

The real test is a reboot. After sudo systemctl reboot and a fresh SSH login, the unit was already active and the key written before the reboot was still there, so the check covers both the start at boot and the data on disk.

systemctl --user is-active redis.service
redis-cli GET probe:selinux

Both answers came back as expected, which proves lingering, the generated unit and the relabelled data directory all work together. If any one of them were missing, the service would not be active or the key would be gone.

active
ok

In the capture below, the unit status from the first start sits next to the two checks run after the reboot on the same Rocky box.

Redis Quadlet systemd user unit active on Rocky Linux 10 and the stored key still present after reboot

The redis-cli in that second command is the two-line shell setup from Step 6, with podman exec in the alias. A fresh login after the reboot starts without it, so run those two lines again first, or add them to ~/.bashrc so every session has them.

Step 6: Connect with redis-cli without exposing the password

The redis-cli binary already sits inside the image, so there is nothing to install on the host. Two shell lines make it feel local. The first exports the password into REDISCLI_AUTH, the variable redis-cli reads when no -a is given (an explicit -a or --askpass wins over it). The second makes redis-cli run inside the container and passes that variable through by name, so the value never appears in any process argument list. That matters on a shared host, because anyone who can run ps would otherwise read a password typed after -a, and we want the setup in Step 2 to keep working the same way for every command that follows.

export REDISCLI_AUTH="$(cat ~/redis-lab/default.pass)"
alias redis-cli='docker exec -i -e REDISCLI_AUTH redis redis-cli'

On the Podman host the alias is the same with podman exec in place of docker exec. Test the connection with a PING, which needs the password and so proves the variable reached the server.

redis-cli PING

A PONG means the password reached the server and was accepted. Any authentication error here points to the exported variable, not to the container.

PONG

One trap with the alias is that shells expand aliases only as the first word of a command. A line such as timeout 3 redis-cli MONITOR therefore looks for a real redis-cli binary on the host, and the Rust coreutils on Ubuntu 26.04 report the miss like this.

timeout: failed to execute process: No such file or directory (os error 2)

For anything wrapped in timeout, put the timeout inside the container instead, as shown in Step 9. To avoid the environment variable entirely, --askpass reads the password from stdin, so this form keeps the password out of both argv and the environment of your shell.

docker exec -i redis redis-cli --user app --askpass GET app:visits < ~/redis-lab/app.pass

It returned the stored value 1 for the app user created in Step 11. From another machine or a client container you connect with -h and -p in the usual way, still with the variable passed through, so the password stays out of the argument list there too.

docker run --rm --network host -e REDISCLI_AUTH redis:8.10.3 redis-cli -h 127.0.0.1 -p 6379 PING

A throwaway client container on the host network printed PONG, which shows that a remote client needs only the address, the port and the same password handling. A graphical client connects the same way; the Redis GUI walkthrough covers that side.

Read server info and change settings live

INFO is split into sections, and asking for one keeps the output readable. The memory section on a fresh instance is a useful baseline, because every later reading can be compared against it. Save the output somewhere before you load data, so a growth figure has a starting point.

redis-cli INFO memory | grep -E 'used_memory_human|used_memory_rss_human|maxmemory_human|maxmemory_policy|mem_fragmentation_ratio'

No memory cap and no eviction is the image default. Check the maxmemory and policy lines in this output before anything else, because they decide what happens when the box runs low on RAM. With the image defaults, the answer is that nothing is evicted and the server keeps growing.

used_memory_human:1.40M
used_memory_rss_human:24.27M
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:17.52

A fragmentation ratio of 17.52 looks alarming, but it is RSS divided by a dataset of 1.4 MB, and the loaded modules dominate RSS on an empty server. Judge that ratio only once the dataset reaches hundreds of megabytes. The setting that matters on day one is maxmemory, because with noeviction and no cap Redis grows until the OOM killer of the kernel picks a process. Read the current values with a glob.

redis-cli CONFIG GET 'maxmemory*'

Raw mode prints each name and value on its own line, so the output alternates between the setting and its current value. We read it in pairs, because the glob matched five maxmemory settings and each name sits directly above its value.

maxmemory
0
maxmemory-eviction-tenacity
10
maxmemory-clients
0
maxmemory-policy
noeviction
maxmemory-samples
5

Set a cap and an eviction policy for a cache workload. Both return OK and apply at once, with no restart, which makes them safe to try on a running server.

redis-cli CONFIG SET maxmemory 256mb
redis-cli CONFIG SET maxmemory-policy allkeys-lru

Reading it back gives bytes, 268435456. These changes live only in memory. CONFIG REWRITE would normally save them to the config file, but our file is mounted read-only, so it fails.

redis-cli CONFIG REWRITE

The error is deliberate, because the read-only mount from Step 3 stops anyone from changing the file through the running server. We chose that mount on purpose, so the file in Git stays the only source of the configuration.

ERR Rewriting config file: Permission denied

We prefer it that way. A container config should come from the file you keep in Git, so add maxmemory 256mb and maxmemory-policy allkeys-lru to ~/redis-lab/redis.conf and restart the container when you want them to stick.

Step 7: Load test keys and use SCAN instead of KEYS

An empty server hides the difference between KEYS and SCAN, so load 100,000 string keys first. The --pipe flag streams everything on stdin to the server in one go and waits only for the last reply, which makes a bulk load far quicker than 100,000 separate calls. The awk line feeds plain inline commands, which is fine for simple keys and values; for binary-safe loads, generate raw RESP protocol as the Redis mass insertion guide describes.

time (seq 1 100000 | awk '{print "SET user:"$1" value-"$1}' | redis-cli --pipe)

All 100,000 writes landed in under half a second with zero errors. The errors line matters more than the timing, because a silent failure would leave the scan tests below with fewer keys than they assume. A clean load also makes the later timings repeatable from run to run.

All data transferred. Waiting for the last reply...
Last reply received from server.
errors: 0, replies: 100000

real	0m0.490s
user	0m0.077s
sys	0m0.037s

Now time both ways of finding the 11 keys that start with user:9999. The wall-clock time is only half of the comparison, as the result shows.

time redis-cli KEYS 'user:9999*' | wc -l
time redis-cli --scan --pattern 'user:9999*' | wc -l

Both return 11 keys, and KEYS finished first at 0.097 seconds against 0.629 seconds for --scan. That is the trap. KEYS wins on wall-clock time for the client because it does the whole walk in one call, but during that call the single-threaded server answers nobody else. The --scan mode takes longer because it pages through the keyspace in many small calls, and other clients get served between them. To see what the blocking costs, lower the slow log threshold to 1 ms and run an unfiltered KEYS.

redis-cli CONFIG SET slowlog-log-slower-than 1000
redis-cli SLOWLOG RESET
redis-cli KEYS 'user:*' | wc -l
redis-cli SLOWLOG GET 2

In raw mode the entry is flattened to one value per line, so read it in order. The fields are the entry ID 1, a Unix timestamp, the duration in microseconds, the command and its argument, the client address, an empty client name, and the total argument count. That last value is a seventh field that SLOWLOG GET gained in Redis 8.10.

1
1794383388
19368
KEYS
user:*
127.0.0.1:37980

2

The server was blocked for 19.4 ms to return 100,000 names. Scaled linearly to a million keys (our estimate, not a measurement) that is roughly 200 ms, long enough to trip application timeouts, so an unfiltered KEYS has no place on a live server. The slow log is the tool that caught it, because it records the duration of every command above the threshold, and we recommend checking it after any bulk operation to see whether a single call held the server for too long. Put the threshold back to its default with redis-cli CONFIG SET slowlog-log-slower-than 10000 when you are done.

redis-cli bulk load of 100000 keys, KEYS versus SCAN timing and SLOWLOG entry showing KEYS blocked for 19368 microseconds

Raw SCAN has one more surprise. A single page can come back empty while the cursor is still non-zero, so an empty reply does not mean the scan is finished. We hit this on the 100,000 keys loaded earlier, which is why the next two captures show the cursor and the empty page.

redis-cli SCAN 0 MATCH 'user:9999*' COUNT 1000

Line one is the next cursor, and the empty second line holds the matches of this page. A non-zero cursor with no matches is exactly the case that trips naive scripts.

49472

MATCH filters after the page is read, so a script that stops at the first empty page misses keys. Loop until the cursor returns to 0, or let --scan do the looping for you. The built-in loop is the safer choice, because it cannot stop early on an empty page.

Step 8: Work with strings, TTLs, hashes, lists and sets

Expiry is where most cache bugs live, so the TTL return codes are worth learning once. Set a session key with a 300-second lifetime and walk it through each state.

redis-cli SET session:42 token-abc EX 300
redis-cli TTL session:42
redis-cli EXPIRE session:42 60
redis-cli PERSIST session:42
redis-cli TTL session:42
redis-cli TTL nosuchkey

Replies come back one per command, and each value means something different.

  • 299: seconds left on the key, one less than the 300 it was given.
  • 1 and 1: the EXPIRE and the PERSIST both succeeded.
  • -1: the key exists but has no expiry.
  • -2: the key does not exist.

Raw replies below follow that order, so match each line to the list above.

OK
299
1
1
-1
-2

A -1 on a key you meant to expire is the classic leak, because a plain SET without EX silently removes an existing TTL. SET with NX and EX also gives you a simple lock, set only if nobody holds it, so a crashed holder cannot block others forever. The expiry is the safety net, because a lock without one stays held until someone deletes the key by hand, and that is why we never set it without EX.

redis-cli SET lock:job1 worker-a NX EX 30
redis-cli SET lock:job1 worker-b NX EX 30
redis-cli GET lock:job1

The first call printed OK, the second printed an empty line (a nil reply in raw mode, meaning the lock was taken) and GET returned worker-a. Hashes hold the fields of an object under one key. We use profile:1001 here because user:1001 is already a string from the bulk load, and HSET on a string key fails with WRONGTYPE Operation against a key holding the wrong kind of value.

redis-cli HSET profile:1001 name ada plan pro logins 0
redis-cli HINCRBY profile:1001 logins 1
redis-cli HGETALL profile:1001

HSET reports 3 new fields, HINCRBY returns the new count, and HGETALL alternates field and value lines. Because the reply is flat in raw mode, a script has to pair the lines itself.

3
1
name
ada
plan
pro
logins
1

Lists work as queues. RPUSH appends, LPOP takes from the head, and BLPOP waits for an item with a timeout, so a worker can sleep until a job arrives instead of polling. The timeout argument matters, because without one the call waits for as long as the list stays empty.

redis-cli RPUSH queue:emails job1 job2 job3
redis-cli LPOP queue:emails
redis-cli LLEN queue:emails
time redis-cli BLPOP queue:empty 2

The list grows to 3, LPOP returns job1, 2 items remain, and BLPOP on an empty list returned nothing after 2.139 seconds, the 2-second wait plus about 0.14 seconds of docker exec start-up. Sets keep unique members and answer membership and intersection questions.

redis-cli SADD tags:post1 redis docker podman
redis-cli SADD tags:post2 redis valkey
redis-cli SISMEMBER tags:post1 docker
redis-cli SINTER tags:post1 tags:post2

The replies are 3 and 2 members added, 1 for “docker is a member”, and redis as the only shared tag. When a key misbehaves, three commands tell you what it is and what it costs, so run them before guessing. Each one reads a single key and returns at once, which makes them safe to try on a live server while you decide what to do next.

redis-cli TYPE profile:1001
redis-cli OBJECT ENCODING profile:1001
redis-cli MEMORY USAGE profile:1001

The answers were hash, listpack and 70 bytes. Small hashes use the compact listpack encoding and switch to a real hash table once they pass hash-max-listpack-entries or hold a value longer than hash-max-listpack-value (512 fields and 64 bytes by default; redis-cli CONFIG GET 'hash-max-listpack-*' printed both on our server). That switch is when their memory use per field jumps, so a hash of 70 bytes is no guide to the cost of a large one.

Step 9: Find slow commands, big keys and latency

MONITOR prints every command the server receives, and it is the one redis-cli mode you must always bound. Running timeout on the host around docker exec looks right, but on our box it left the monitor running inside the container after the host side was killed. The check below lists the connected clients to prove it.

timeout 3 docker exec -i -e REDISCLI_AUTH redis redis-cli MONITOR
redis-cli CLIENT LIST | grep 'flags=O' | cut -d' ' -f1-3

The O flag marks a monitor client, and one was still attached after timeout had ended the host-side command. Killing the host-side process therefore did not end the session on the server.

id=26 addr=127.0.0.1:38274 laddr=127.0.0.1:6379

An orphaned monitor costs throughput for as long as it lives, because the server copies every command to it. Kill it by ID with redis-cli CLIENT KILL ID 26, then run the timeout inside the container so it ends the client itself. The background job writes a key one second in, so there is something to see in the stream.

(sleep 1; redis-cli SET probe 2 >/dev/null) & docker exec -e REDISCLI_AUTH redis timeout 3 redis-cli MONITOR

Passwords are redacted in the stream, so a monitor capture is safe to paste into a ticket. Afterwards redis-cli CLIENT LIST | grep -c 'flags=O' printed 0, which shows the in-container timeout cleaned up after itself. Use that count after every monitor session, since an orphan costs throughput until someone removes it.

OK
1794384072.931575 [0 127.0.0.1:50954] "AUTH" "(redacted)"
1794384072.931815 [0 127.0.0.1:50954] "SET" "probe" "2"

Latency mode needs no timeout at all through the alias. Without a TTY, redis-cli samples for one second, prints one summary line and exits, which suits a log file (in a real terminal it keeps redrawing until Ctrl+C).

redis-cli --latency

The four columns are minimum, maximum and average round trip in milliseconds, then the sample count. The maximum is the figure to watch, because an average hides the occasional slow reply. Here the maximum of 0.584 ms stays close to the 0.250 ms average over 98 samples, so no outliers appeared in this run.

0.114 0.584 0.250 98

Sub-millisecond figures like these are normal for loopback on a cloud VM. To tell whether a spike comes from Redis or from the hypervisor, measure the host itself. The --intrinsic-latency mode runs no Redis commands at all, because it times a busy loop on the CPU.

redis-cli --intrinsic-latency 5

The last two lines carry the verdict, since they report the worst pause the scheduler caused while the loop ran.

Max latency so far: 209 microseconds.

96814192 total runs (avg latency: 0.0516 microseconds / 51.65 nanoseconds per run).
Worst run took 4047x longer than the average latency.

A 209 Β΅s worst case from the scheduler alone means no Redis command on this VM can be reliably faster than about 0.2 ms at the tail. Anything far above that in --latency points at Redis or the network path, not the host.

Find the biggest keys

Add one deliberately large list so the scans have something to find, because a clean dataset gives a big key scan nothing to rank.

seq 1 50000 | awk '{print "RPUSH big:list item-"$1}' | redis-cli --pipe

Three scan modes then answer different questions, so pick the one that matches the problem you are chasing.

  • --bigkeys: ranks keys by element count, which finds the list with the most items.
  • --memkeys: ranks keys by bytes, which finds what actually uses memory.
  • --keystats: adds size percentiles, which shows how the whole keyspace is distributed.

Run all three against the same server, since each one reads the data from a different angle.

redis-cli --bigkeys | tail -n 13
redis-cli --memkeys | tail -n 11

The --memkeys summary puts the 50,000-item list at 592,400 bytes, while the average string costs 47.92 bytes. One key therefore weighs as much as thousands of ordinary ones, which is what a big key scan exists to expose.

Biggest   list found "big:list" has 592400 bytes
Biggest   hash found "profile:1001" has 70 bytes
Biggest string found "session:43" has 56 bytes
Biggest    set found "tags:post1" has 59 bytes

1 lists with 592400 bytes (00.00% of keys, avg size 592400.00)
1 hashs with 70 bytes (00.00% of keys, avg size 70.00)
0 streams with 0 bytes (00.00% of keys, avg size 0.00)
100004 strings with 4792180 bytes (100.00% of keys, avg size 47.92)
2 sets with 110 bytes (00.00% of keys, avg size 55.00)
0 zsets with 0 bytes (00.00% of keys, avg size 0.00)

The two modes disagree on the biggest string. --bigkeys picked user:100000 for its 12-byte value, while --memkeys picked a session: key at 56 bytes, because it counts the key name and allocator overhead as well as the value. (Our capture names session:43, a key from a side test; on your run it is session:42, which held 56 bytes in the first pass too.) When memory is the problem, trust --memkeys. --keystats is the better report for capacity planning:

redis-cli --keystats | tail -n 20

Its percentile table shows that 99.994% of keys are 48 bytes or less and a single key, the list, accounts for 578.53K:

Key size Percentile Total keys
-------- ---------- -----------
     29B    0.0010%           1
     48B   99.9940%      100002
     56B   99.9970%      100005
     70B   99.9990%      100007
 578.53K  100.0000%      100008
Note: 0.01% size precision, Mean: 53B, StdDeviation: 1.83K

Key name length Percentile Total keys
--------------- ---------- -----------
            12B  100.0000%      100008
Total key length is 965.80K (9B avg)

Type        Total keys  Keys % Tot size Avg size  Total length/card Avg ln/card
--------- ------------ ------- -------- -------- ------------------ -----------
list                 1   0.00%  578.52K  578.52K        50000 items    50000.00
hash                 1   0.00%      70B      70B           3 fields        3.00
string          100004 100.00%    4.57M      47B              1.04M         11B
set                  2   0.00%     110B      55B          5 members        2.50

All three modes use SCAN internally, so they are safe on a live server. Remove a large key with redis-cli UNLINK big:list rather than DEL; UNLINK frees the memory in a background thread instead of blocking for the whole list. On a list of 50,000 items that difference decides whether other clients notice the cleanup.

redis-cli --bigkeys and --memkeys summaries finding a 50000 item list on Redis 8.10.3

The 50,000-item list stands out in every report, which is exactly what you want from a scan before an incident rather than during one.

Step 10: Check that persistence survives a restart

A container that loses its keys on restart is usually missing the /data volume or an AOF setting, so test persistence before you trust it with data. Trigger a snapshot and read the persistence counters, because they show whether the last save succeeded and whether AOF is active.

redis-cli BGSAVE
redis-cli INFO persistence | grep -E 'rdb_last_bgsave_status|rdb_last_bgsave_time_sec|rdb_changes_since_last_save|aof_enabled|aof_last_write_status'

After Background saving started, the counters show the snapshot succeeded in under a second and AOF is on. Both facts matter, because the config from Step 2 asks for AOF with a one-second fsync, which loses at most about a second of writes.

rdb_changes_since_last_save:0
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
aof_enabled:1
aof_last_write_status:ok

Look at the files Redis wrote into the volume, because the sizes show how much disk each persistence mode costs and which one grows faster as writes accumulate. The snapshot and the append-only files are separate, so both appear in the listing.

docker exec redis ls -la /data /data/appendonlydir

The RDB snapshot is 2.9 MB, while the AOF increment file has grown to 7.0 MB. The gap comes from what each file stores, as the next paragraph works out.

/data:
total 2868
drwxr-xr-x 3 redis redis    4096 Nov 11 07:53 .
drwxr-xr-x 1 root  root     4096 Nov 11 07:48 ..
drwx------ 2 redis redis    4096 Nov 11 07:48 appendonlydir
-rw------- 1 redis redis 2924463 Nov 11 07:53 dump.rdb

/data/appendonlydir:
total 6900
drwx------ 2 redis redis    4096 Nov 11 07:48 .
drwxr-xr-x 3 redis redis    4096 Nov 11 07:53 ..
-rw------- 1 redis redis      89 Nov 11 07:48 appendonly.aof.1.base.rdb
-rw------- 1 redis redis 7046471 Nov 11 07:50 appendonly.aof.1.incr.aof
-rw------- 1 redis redis     102 Nov 11 07:48 appendonly.aof.manifest

The AOF is 2.4 times the size of the snapshot because it logs every write, including the 50,000 RPUSH calls, until a rewrite compacts it into a new base file. That ratio is the number to watch on disk, so size the volume for the AOF and not for the snapshot. The figure above is a moment in time, not a limit. Now restart and count the keys, because a matching total is the proof that the data was read back from the volume.

redis-cli DBSIZE; docker restart redis >/dev/null && sleep 2 && redis-cli DBSIZE

The count before and after the restart is identical:

100007
100007

Every one of the 100,007 keys came back. Keys with a TTL would be the only legitimate difference, because they can expire while the container is down. LASTSAVE returns the Unix time of the last successful save, so it is the value to alert on if it stops moving, because a frozen timestamp means saves are failing silently.

Step 11: Create a least-privilege ACL user

Applications should not share the default user’s password. Create an app user limited to keys under app:*, and feed its password through stdin with -x so it never appears in argv. The > prefix is ACL syntax for “add this password”, so the value piped in on stdin carries that prefix.

openssl rand -hex 24 > ~/redis-lab/app.pass && chmod 600 ~/redis-lab/app.pass
printf '>%s' "$(cat ~/redis-lab/app.pass)" | redis-cli -x ACL SETUSER app on resetkeys '~app:*' resetchannels '+@read' '+@write' '-@dangerous'

Test the rules without logging in as the user. ACL DRYRUN runs the permission check only, so nothing is written and no session is opened, which makes it safe to repeat while you tune the patterns. Run it with a key the user should reach and one it should not, because both answers are needed to trust a rule.

redis-cli ACL DRYRUN app SET app:visits 1
redis-cli ACL DRYRUN app GET user:1

Redis allows the first command and refuses the second, because that key sits outside the app:* pattern. A dry run per key pattern is a cheap way to confirm the rule before any application uses it.

OK
User app has no permissions to access the 'user:1' key

Then log in for real, overriding REDISCLI_AUTH for one command only. The write succeeds, but the user cannot even ask who it is, because the account was granted data commands and nothing else.

REDISCLI_AUTH="$(cat ~/redis-lab/app.pass)" redis-cli --user app SET app:visits 1
REDISCLI_AUTH="$(cat ~/redis-lab/app.pass)" redis-cli --user app ACL WHOAMI

The write returns OK, then the identity query is denied. That pair shows the rules work in both directions, because the same user is allowed one command and refused the next.

OK
NOPERM User app has no permissions to run the 'acl|whoami' command

Health checks are the next thing to break, because connection pools send PING and the app user has no right to it yet. Try it before granting anything, so you know which error your pool will log.

REDISCLI_AUTH="$(cat ~/redis-lab/app.pass)" redis-cli --user app PING

The refusal names the command, which tells you exactly what to grant.

NOPERM User app has no permissions to run the 'ping' command

Our first fix was +@connection, the category that holds PING and ECHO. It also holds CLIENT KILL and CLIENT PAUSE, and because ACL rules apply left to right, a +@connection written after -@dangerous hands those back. A throwaway user built that way passed ACL DRYRUN probe CLIENT KILL ID 1 with OK on our server, so the app could have disconnected every other client. Grant the individual commands instead:

redis-cli ACL SETUSER app '+ping' '+echo' '+client|setname'
REDISCLI_AUTH="$(cat ~/redis-lab/app.pass)" redis-cli --user app PING
redis-cli ACL DRYRUN app CLIENT KILL ID 1

The SETUSER returns OK, the app user now gets its PONG, and the dry run proves the dangerous client commands stay out of reach. CLIENT SETNAME is there for client libraries that name their connections; drop it if yours does not.

OK
PONG
User app has no permissions to run the 'client|kill' command

Running redis-cli ACL LOG 1 on the default user shows the earlier denial with the client address, the reason and the command, which is how you find a misconfigured service. Check the final rule set:

redis-cli ACL GETUSER app | grep -A1 -E '^(commands|keys)$'

The command rules start from -@all and add only what we granted. Anything not listed stays denied. The only categories granted are @read and @write, both trimmed by -@dangerous, and a command a later Redis release tags into one of them would reach this user, so grant everything else by command name. That default-deny shape is what makes the account least-privilege, as long as every later grant names commands rather than whole categories.

commands
-@all +@read +@write -@dangerous +ping +echo +client|setname
keys
~app:*

The full ACL sequence from the Ubuntu box, from the dry runs to the refused CLIENT KILL:

redis-cli ACL app user denied PING until +ping is granted, with CLIENT KILL still refused and the final rule set

Runtime users disappear on restart. ACL SAVE needs an aclfile directive (ours has none, so it returns an error), and CONFIG REWRITE cannot write the read-only config. We confirmed the loss with docker restart redis, after which ACL USERS listed only default. The fix that fits a read-only config is to declare the user in redis.conf:

printf 'user app on >%s ~app:* resetchannels +@read +@write -@dangerous +ping +echo +client|setname\n' "$(cat ~/redis-lab/app.pass)" >> ~/redis-lab/redis.conf
docker restart redis >/dev/null && sleep 2 && redis-cli ACL USERS

Both users survive the restart this time, because the definition now lives in the config file that Redis reads at every start.

app
default

The two-second pause in that command matters, because the container needs a moment to accept connections again. Without it, one of our runs raced the restart and got Could not connect to Redis at 127.0.0.1:6379: Connection refused.

Step 12: Run Valkey as a protocol-compatible alternative

Valkey is the Linux Foundation fork of Redis 7.2.4 and speaks the same protocol, so clients and redis-cli work against it. Its data files are another matter: the Valkey migration guide states that RDB files written by Redis 7.4 and later cannot be loaded, which includes the redis-data volume from this guide. Start Valkey on a fresh volume and move data key by key, not by copying files. Run it next to Redis on another loopback port; the tag is the current stable from the Valkey releases page:

docker run -d --name valkey -p 127.0.0.1:6380:6379 valkey/valkey:9.1.3 # https://github.com/valkey-io/valkey/releases

The redis-cli from the Redis 8 image talks to it without any change, because Valkey keeps the same protocol. Ask the server on the new port to identify itself:

docker run --rm --network host redis:8.10.3 redis-cli -p 6380 INFO server | grep -E 'server_name|valkey_version'

Valkey identifies itself by name and version, so you can tell the two servers apart when both run on one host. Check this before pointing an application at the wrong port, because the two answer the same commands and the mistake would go unnoticed.

server_name:valkey
valkey_version:9.1.3

Inside its own container the client is called valkey-cli, and its INFO still reports redis_version:7.2.4 for client libraries that branch on it. We ran only PING and INFO against Valkey from the Redis 8 client, and both worked unchanged; the rest of this cheat sheet was tested on Redis only. The Valkey vs Redis comparison covers licensing and the RDB-safe migration path if you are deciding between them.

Docker vs rootless Podman: measured Redis throughput

The throughput figures in the introduction come from redis-benchmark with 200,000 requests and 50 clients, three runs per path, against a throwaway unauthenticated container on each engine. The client ran on the host network for the published-port rows and inside the server container for the loopback row, so the gap between them isolates the cost of the port path. Start one throwaway server per engine, with no password and no volume:

docker run -d --name bench-docker -p 127.0.0.1:6390:6379 redis:8.10.3
podman run -d --name bench-podman -p 127.0.0.1:6391:6379 docker.io/library/redis:8.10.3

Then point the benchmark at each published port (6391 for Podman) and, for the loopback row, run it inside the container with docker exec bench-docker redis-benchmark -q -n 200000 -c 50 -t set,get:

docker run --rm --network host redis:8.10.3 redis-benchmark -p 6390 -q -n 200000 -c 50 -t set,get | tr '\r' '\n' | grep 'requests per second'

The tr step matters because -q redraws a progress line with carriage returns, and without it a log file fills with 70 KB of partial lines. Each run prints two result lines, one for SET and one for GET, so three runs give six numbers per path.

SET: 21281.12 requests per second, p50=1.831 msec
GET: 21588.95 requests per second, p50=1.791 msec

Here are all runs, as SET requests per second. GET stayed within about 2.2% of SET on every Ubuntu run; on Rocky the gap reached 12% in one in-container run, which is part of why the Rocky rows count as noisy. Each cell is one run, which lets you judge the spread yourself.

Host and pathRun 1Run 2Run 3p50 latency
Ubuntu 26.04, Docker published port 127.0.0.121,28121,45221,3331.80-1.83 ms
Ubuntu 26.04, rootless Podman published port25,17925,27825,0001.63-1.71 ms
Ubuntu 26.04, inside the Docker container44,63345,14744,6630.57 ms
Rocky Linux 10, rootless Podman published port20,94720,93119,7371.45-1.57 ms
Rocky Linux 10, inside the Podman container40,10437,03034,9410.62-0.64 ms

Read the table in three ways, because each comparison answers a different question and only the same-box rows are fair to compare directly.

  • Published port vs in-container: the port path halves throughput on both engines, from about 44,800 to 21,400 on Docker. With 2 vCPUs, the benchmark client, the port forwarder and Redis compete for the same cores, so this is a worst case; a client on another machine does not pay the forwarder’s CPU on the Redis host.
  • Docker vs rootless Podman on Ubuntu: Podman’s published port was 18% faster than Docker’s docker-proxy path, run after run, with spreads under 1.2%. Rootless networking is no longer the penalty it was in older Podman releases.
  • Ubuntu vs Rocky: the Rocky box was slower and noisier, with the in-container runs spreading 13% from best to worst. Treat cross-VM comparisons on shared cloud cores as indicative only; the same-box rows are the ones to trust.

One oddity: Rocky’s published port had a lower p50 latency (1.45 to 1.57 ms) than Ubuntu’s Docker port (1.80 to 1.83 ms) despite lower throughput, so its slower runs came from the tail, not the typical request. Memory was not a differentiator: an idle benchmark container used 5.7 MiB under Docker and 5.8 MB under Podman.

For a cache that only local containers reach, skip the published port entirely and put the application on the same Docker network or Podman pod, which keeps it on the faster in-container path. When an application on the host itself must connect, rootless Podman is the faster and safer default on Ubuntu, and on Rocky it is the only engine that handles SELinux labels without daemon changes. For dashboards on top of these numbers, the Redis Prometheus and Grafana setup exports the same INFO counters this cheat sheet reads by hand, and the Redis books we checked against Redis 8 go deeper on data modelling.

Keep reading

Claude Code Cheat Sheet: Commands, Shortcuts and Flags (PDF) AI Claude Code Cheat Sheet: Commands, Shortcuts and Flags (PDF) OpenAI Codex CLI Cheat Sheet: Shortcuts, Commands, Flags (PDF) AI OpenAI Codex CLI Cheat Sheet: Shortcuts, Commands, Flags (PDF) Best UI Applications for Managing Docker Containers Containers Best UI Applications for Managing Docker Containers OpenCloud vs ownCloud vs Nextcloud: Tested on Identical VMs Cloud OpenCloud vs ownCloud vs Nextcloud: Tested on Identical VMs Kiri Container Runtime on Linux: Install and Benchmark vs Docker Containers Kiri Container Runtime on Linux: Install and Benchmark vs Docker Run Teleport in Docker Container using Docker Compose Containers Run Teleport in Docker Container using Docker Compose

Leave a Comment

Press ESC to close