[dropcap]W[/dropcap]hen reading this post, I am thinking of the fact that you are curious at the reasons why we have to do so and why we don’t install Redis Server on our system and run it as the typical software. I am going to explain some understandable reasons to you right now.
Table of Contents
Why do we run Redis Server on Docker?
There are a couple of benefits coming up from my mind when writing this post which can be listed below.
- First and foremost, it is rapid and simple. Find the right Redis Server docker image, pull and run.
- Obviously, the docker image is optimised to be small and neat so that it won’t swallow a lot of resource of your system.
- You don’t have to be frustrated to install Redis Server because you might have the trouble of installing it on your machine.
- Ease maintenance and management of the software installed on your system. If you want to upgrade Redis Server, just pull a new image and that’s it.
How to do so?
In my context, we need a Redis Server 5.0.3 to cache essential data being used for the landing page to speed loading the page. What I have been doing is
Search for a compatible Redis Server on Docker hub
Going to Docker hub, search for Redis from the main search box. Clicking on Redis link and choosing Tags. I typed 5.0.3 into the search box as you see in the screenshot below.
Download a docker image
On the top right of each result box showing a matched image, you can find the command to download/pull that image.
docker pull redis:5.0.3-alpine3.9 --- 5.0.3-alpine3.9: Pulling from library/redis 8e402f1a9c57: Pull complete 4c2113a1bbc9: Pull complete a4b5ad98d179: Pull complete 4db6e55a035b: Pull complete ec250a8373f4: Pull complete 22c03918a60a: Pull complete Digest: sha256:f8c22abc77f3f9cc1c2516062e4a2a71375859d7922da3faf9e4160e6ba4c3c2 Status: Downloaded newer image for redis:5.0.3-alpine3.9 docker.io/library/redis:5.0.3-alpine3.9
Verify the downloading
docker image ls --- redis 6.0-alpine 360360313017 2 weeks ago 31.6MB redis 5.0.9-alpine3.11 3661c84ee9d0 3 weeks ago 29.8MB biomodels/jummp-biomodels 1.2-dependencies 1c2bdf975661 8 months ago 1.26GB redis 5.0.3-alpine3.9 3d2a373f46ae 14 months ago 50.8MB redis 5.0.3 0f88f9be5839 14 months ago 95MB tomcat 8.0-alpine 624fb61775c3 20 months ago 147MB ubuntu 16.04 c9d990395902 2 years ago 113MB grails3demo_app-web latest 8275889343f6 2 years ago 410MB
Run the Redis Server image
Typically, run the server in the interactive mode
docker run -it --rm redis:5.0.3-alpine3.9
However, at least in my use case, I want to reuse this Redis Server in my application, therefore it is going to be restarted. For that reason, I run it under a specific name and don’t specify the option –rm.
docker run -it --name redis_server redis:5.0.3-alpine3.9
Start the Redis Server
As I said earlier, when running an image under a name and stopping it, the container isn’t removed. Therefore, you must start it instead of running. Naturally, we just start the container that has been shut down early.
docker start -it redis_server # redis_server is the name of Redis Server
On Windows 10, open Docker dashboard to manage the existing containers. I also restarted my Redis Server from the dashboard.
That’s it. I hope this post helps you improve your development. If you are interested in related topics, please take a look at How to deploy your web apps to a Docker container.