Redis
What is Redis?
Redis is an in-memory data store used as a cache, session store, and queue backend. It's the most common performance upgrade for PHP apps once file-based caching or array sessions stop being enough, and Laravel supports it natively.
Start Redis
docker compose up -d redis
Stop Redis
docker compose stop redis
This stops the container without deleting its data. To remove the container (data on disk is untouched, it lives under DATA_PATH_HOST): docker compose rm -f redis.
Configuration
redis/defaults.env holds the port, and the password lives in the main .env (uncomment/edit the line under the ### REDIS section). Either can be overridden in your own .env:
| Variable | Default | What it does |
|---|---|---|
REDIS_PORT | 6379 | Host-side port Redis is published on (host:container). |
REDIS_PASSWORD | secret_redis | Passed to the container as --requirepass; set it empty to disable auth. |
Use Redis from Laravel
- In your Laravel
.env, setREDIS_HOST=redis. If that variable isn't there, editconfig/database.phpinstead and replace the default127.0.0.1withredis:'redis' => ['cluster' => false,'default' => ['host' => 'redis','port' => 6379,'database' => 0,],], - To use Redis for cache and sessions, set
CACHE_DRIVER=redisandSESSION_DRIVER=redisin.env. - Install the client:
composer require predis/predis:^1.0
- Test it from Laravel:
\Cache::store('redis')->put('Laradock', 'Awesome', 10);
Use the redis-cli
docker compose exec redis bash
redis-cli
If REDIS_PASSWORD is set, authenticate first: redis-cli -a secret_redis.
Connect from your host machine
Inside Laradock, other containers reach Redis by container name: REDIS_HOST=redis. From your own machine, connect to localhost:6379 (or your custom REDIS_PORT) with a GUI like TablePlus or RedisInsight, using REDIS_PASSWORD if set.
Common issues
NOAUTH Authentication required.REDIS_PASSWORDis set in.envbut your client isn't sending it. Pass-a <password>toredis-cli, or set the password on your Laravel Redis connection config.- App can't connect but the container is running. Confirm the app's
.envusesREDIS_HOST=redis(the container name), notlocalhostor127.0.0.1, those only work from your host machine, not from inside another container. - Port already in use on your host. Another local Redis (or another Laradock project) is already bound to
6379. ChangeREDIS_PORTin.envand restart:docker compose up -d redis. - Data disappears after
docker compose down -v. Redis data lives underDATA_PATH_HOST/redis;-vremoves named volumes and, depending on your setup, can wipe it. Usedocker compose stopif you just want to pause the container.
Need a GUI to browse keys? See Redis WebUI. Need a Redis-compatible alternative? See Valkey or Dragonfly, or a multi-node setup, Redis Cluster. New to Laradock? Start at Getting Started.