Reputation: 5422
This is chunk of my docker-compose.yml
:
redis:
image: redis:alpine
container_name: foo_redis
volumes:
- ./docker/volumes/redis:/data
restart: unless-stopped
ports:
- 6379:6379
networks:
- local_network
I can guarantee that data persists between ups
and downs
because I've defined volumes
.
I can prove that data is being stored physically because I see dump.rdb
within ./docker/volumes/redis
on my host machine.
Then from my host machine I do:
docker exec -it foo_redis redis-cli
I get a prompt:
127.0.0.1:6379>
I type KEYS *
and I get:
127.0.0.1:6379> KEYS *
(empty array)
127.0.0.1:6379>
Why? What am I doing wrong? Redis seems to works fine. My Laravel app has predis
and caching works with no issues.
edit:
My .env
looks like:
CACHE_DRIVER=redis
REDIS_CLIENT=predis
REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379
edit 2:
When I manually put something into redis, it shows only that thing.
127.0.0.1:6379> set hello world
OK
127.0.0.1:6379> get hello
"world"
127.0.0.1:6379> KEYS *
1) "hello"
127.0.0.1:6379>
Upvotes: 5
Views: 3446
Reputation: 143
The old answer, but maybe will be useful for someone, check the using Redis database number.
If your data contains in the Redis database with a number different from 0 (default number), first set the DB number in CLI mode, using the command SELECT <db number>
Example: https://redis.io/docs/manual/cli/#interactive-mode
Upvotes: 3