Redis is a fast, in-memory data structure store which can be used as a cache for your applications. It supports various data structures such as hashes, sets, bitmaps etc. Here's how to launch a complete redis instance on docker, which can then serve your other applications.
Start by launching a redis server:
docker run --name my-redis -d redis
-d makes it run in the background, and
my-redis is the name of the instance. "redis" is obviously the name of the docker image.
Your docker instance is now up and running on port 6379 (default for redis). It's time to try it out using the redis client (redis-cli):
docker run --link my-redis:redis redis redis-cli -h redis -p 6379
--link option links the redis-cli container to the redis server container. We then specify the image name (
redis-cli), hostname (
redis) and the port (
-p). The CLI should now be visible and we can try sending some commands to our redis server.
Let's begin with a simple ping:
redis 127.0.0.1:6379 ping PONG
Setting a value to "mykey":
redis 127.0.0.1:6379 set mykey somevalue OK
Getting the value:
redis 127.0.0.1:6379 get mykey "somevalue"
You can now go ahead and link your other applications to the redis server, and use it as a fast and flexible storage.
Subscribe to Oskar Lind
Get the latest posts delivered right to your inbox