Build the mental model
Docker gives every learner a consistent environment. Bind only to `127.0.0.1`, use a named volume, and enable AOF persistence. One password is not a production security design, but it is safer than an unauthenticated local service and prepares you for ACL and TLS later.
Connect it to a real scenario
Run `redis:8.10-alpine` with AOF and a password. Pass `REDISCLI_AUTH` as command environment and verify readiness/version with `PING` and `INFO server`. Production credentials belong in a secret manager, not the repository or shell history.
Try the working example
docker volume create redis-data
docker run --name redis-tutorial \
-p 127.0.0.1:6379:6379 \
-v redis-data:/data \
-d redis:8.10-alpine \
redis-server --appendonly yes --requirepass learnredis
docker exec -e REDISCLI_AUTH=learnredis redis-tutorial redis-cli PING
docker exec -e REDISCLI_AUTH=learnredis redis-tutorial redis-cli INFO serverYou see `PONG` and Redis 8.10.x server information.5-minute try-it
Set `setup:test` to `ok`, stop/start the container, and verify that the volume and AOF preserve it.
One important caution
Never expose port 6379 to the public internet. A password alone does not replace network controls, ACLs, and TLS.
Redis CLI — Redis