Ajeet Raina Docker Captain, ARM Innovator & Docker Bangalore Community Leader.

How to setup and run Redis in a Docker Container

1 min read

Redis stands for REmote DIctionary Server. It is an open source, fast NoSQL database written in ANSI C and optimized for speed. Redis is an in-memory database that means that all data in Redis is stored in RAM, delivering the fastest possible access times to the data for both read and write requests.

Redis  is designed and implemented for performance. Redis compiles into extremely efficient machine code and requires little overhead. It uses a (mostly) single threaded event loop model that optimally utilizes the CPU core that it is running on. The data structures used internally by Redis are implemented for maximum performance and the majority of data operations require constant time and space.

Redis is based on the key-value model. In Redis, the data is stored and fetched from Redis by key. Keybased access allows for extremely efficient access times and this model maps naturally to caching, with Redis providing the customary GET and SET semantics for interacting with the data. Also, it supports multi-key operations. Several of Redis’ commands operate on multiple keys. Multi-key operations provide better overall performance compared to performing the operations one after the other, because they require substantially less communication and administration.

Redis is designed to be a remote, network-attached server. It uses a lightweight TCP protocol that has client implementations in every conceivable programming language. Redis is basically an open source, in-memory, data structure store that can be used as a cache, primary database and message broker. It is a multi-model database that supports search, graph, real-time streaming, analytics and many other use cases beyond that of a simple data store. With over 52,000+ GitHub stars, 20,000+ forks and over 500+ contributors, Redis is quite popular among the developers. Redis gives developers building applications the tools and information they need in a very efficient manner. Redis today can be deployed on-premises, across clouds, hybrid environments as well as over the Edge devices flawlessly.

Here’s a quickstart guide to get Redis running in a Docker container:

Ensure that Docker is installed

docker -v

Create a dedicated Docker network

docker network create -d bridge redisnet

Run Redis container

docker run -d -p 6379:6379 --name myredis --network redisnet redis

Install redis-cli

brew install redis-cli

Enter into Redis-cli

redis-cli

Accessing the keys

  • Create a generic key like set a1 100 and get a1 100
set a1 100
get a1

Importing user keys

Let us import a user database( 6k keys). This dataset contains users stored as Redis Hash.

The user hashes contain the following fields:

user:id : The key of the hash.
first_name : First Name.
last_name : Last name.
email : email address.
gender : Gender (male/female).
ip_address : IP address.
country : Country Name.
country_code : Country Code.
city : City of the user.
longitude : Longitude of the user.
latitude : Latitude of the user.
last_login : EPOC time of the last login.

Cloning the repository

git clone https://github.com/redis-developer/redis-datasets
cd redis-datasets/user-database

Importing the user database:

redis-cli -h localhost -p 6379 < ./import_users.redis

Open a new terminal and run the monitor CLI

monitor

Flushing up the database

flushdb

Cleaning up container

docker stop myredis

Further References

Have Queries? Join https://launchpass.com/collabnix

Ajeet Raina Docker Captain, ARM Innovator & Docker Bangalore Community Leader.

71 Replies to “How to setup and run Redis in a Docker…”

  1. How Docker Container Works?

    Docker has become the de facto standard in container-based implementation. Docker is an open-source platform, written in GO language, developed by DotCloud and used by developers to build, deploy and run applications. With Docker, one can easily separate their applications from the infrastructure for the fast delivery of the project. It enables developers to package and run the application in a loosely remote environment called a container. The isolation that Docker provides allows developers to run several containers at the same time on a given host.

  2. Howdy very nice site!! Man .. Beautiful .. Amazing .. I will bookmark your web site and take the feeds also?KI am glad to find so many helpful information right here within the publish, we need develop more techniques on this regard, thank you for sharing. . . . . .

  3. I loved as much as you will receive carried out right here. The sketch is tasteful, your authored subject matter stylish. nonetheless, you command get bought an nervousness over that you wish be delivering the following. unwell unquestionably come more formerly again since exactly the same nearly very often inside case you shield this hike.

  4. Pretty portion of content. I just stumbled upon your website and in accession capital to assert that I get actually enjoyed account your weblog posts. Any way I’ll be subscribing to your feeds or even I achievement you access persistently rapidly.

  5. Superb blog you have here but I was wondering if you knew of any message boards that cover the same topics talked about in this article? I’d really love to be a part of group where I can get feed-back from other knowledgeable people that share the same interest. If you have any recommendations, please let me know. Appreciate it!

  6. I absolutely love your blog and find many of your post’s to be precisely what I’m looking for. Would you offer guest writers to write content for yourself? I wouldn’t mind producing a post or elaborating on a lot of the subjects you write about here. Again, awesome blog!

  7. I do like the way you have presented this specific situation plus it really does supply me personally some fodder for consideration. Nevertheless, coming from what I have witnessed, I simply just hope when other commentary stack on that folks continue to be on issue and in no way start upon a soap box of the news du jour. Anyway, thank you for this superb piece and though I can not necessarily agree with this in totality, I regard the viewpoint.

  8. I was wondering if you ever considered changing the page layout of your site? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or two pictures. Maybe you could space it out better?

  9. You could certainly see your enthusiasm in the work you write. The arena hopes for more passionate writers like you who are not afraid to say how they believe. All the time go after your heart. “We may pass violets looking for roses. We may pass contentment looking for victory.” by Bern Williams.

  10. The next time I read a blog, I hope that it doesnt disappoint me as much as this one. I mean, I know it was my choice to read, but I actually thought youd have something interesting to say. All I hear is a bunch of whining about something that you could fix if you werent too busy looking for attention.

  11. Thanks, I’ve recently been searching for info approximately this topic for a long time and yours is the best I have found out so far. However, what about the bottom line? Are you certain concerning the source?

  12. I’ve been browsing on-line more than three hours today, yet I by no means discovered any interesting article like yours. It is beautiful worth sufficient for me. In my view, if all site owners and bloggers made just right content material as you did, the internet will probably be much more helpful than ever before.

  13. I was very pleased to find this web-site.I wanted to thanks for your time for this wonderful read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you blog post.

  14. you’re really a good webmaster. The site loading speed is amazing. It seems that you are doing any unique trick. Also, The contents are masterpiece. you’ve done a fantastic job on this topic!

  15. My spouse and i have been quite thankful that Edward could do his reports out of the ideas he obtained through the web page. It’s not at all simplistic to simply continually be handing out instructions which usually many others might have been trying to sell. So we fully understand we now have the blog owner to give thanks to for that. The type of illustrations you made, the simple blog navigation, the relationships you can give support to instill – it is mostly impressive, and it’s assisting our son and us know that that subject matter is brilliant, which is unbelievably important. Many thanks for the whole lot!

  16. I’m really loving the theme/design of your web site. Do you ever run into any web browser compatibility issues? A few of my blog audience have complained about my website not operating correctly in Explorer but looks great in Safari. Do you have any solutions to help fix this problem?

  17. Teгrific article! That is the kind of info that arе meant to be shared aгound the net.
    Shame on the seek engines for no longer positioning this post higher!
    Come on over and discuss with my web ѕite . Thank you =)

  18. Hi there, I found your blog via Google while looking for a related topic, your web site came up, it looks great. I’ve bookmarked it in my google bookmarks.

  19. Thank you for the sensible critique. Me & my neighbor were just preparing to do a little research about this. We got a grab a book from our local library but I think I learned more clear from this post. I’m very glad to see such fantastic info being shared freely out there.

  20. How to setup and run Redis in a Docker Container – Collabnix Thank you, How to setup
    and run Redis in a Docker Container – Collabnix I have just been looking for info about
    this How to setup and run Redis in a Docker Container
    – Collabnix topic for How to setup and run Redis in a Docker Container – Collabnix a while
    and yours is the How to setup and run Redis in a Docker
    Container – Collabnix best I’ve came upon till now.
    But, what in regards to the How to setup and run Redis in a Docker Container –
    Collabnix conclusion? Are you How to setup and run Redis in a Docker Container – Collabnix sure in regards to the supply?http://dropref.com/?http://0pi.ru/post.php?url=https://loginken.com/

Leave a Reply

Your email address will not be published.