Redis on Docker
What is covered
- running redis official image on docker
- running redis-cli tool using docker image
What is not covered
- docker
- redis
Note: This is only to be used on developer machine.
Note: This is only to be used on developer machine.
Running redis official docker image
This step is actually very simple.
First get redis image from docker hub
docker pull redis
Now run it
docker run -p 6379:6379 --name redis redis
We ran 'redis' image. And named created container as 'redis'. And exposed port 6379 of container as 6379 on local machine.
Run again using
docker start redis
Stop using
docker stop redis
Run again using
docker start redis
Stop using
docker stop redis
Using redis-cli
One way is to install redis-cli and use it.
But we do not need to. We have all we need within docker image. We execute a bash in same 'redis' container that is running
docker exec -it redis bash
Now in image, we have access to redis-cli. Just fire command below
redis-cli
Location for redis in docker image is: /usr/local/bin/redis-cli
Below are a few commands that can be used to test redis
Find keys: keys *
Add a key-value: set my-key "This is my value"
Get value for a key: get my-key
Comments
Post a Comment