Install Redis From Docker Hub

28/12/2020

Overview

In this post, we will see how we can install and use Redis server from  Docker Hub. Using Docker Hub is very much advantageous as this ensures that we don’t have to reinstall the same version of Redis on our machine and we can test our Redis with multiple versions very quickly. Let’s read more about this.

Using Docker

To start using Docker, we must install it on our System. To do this, visit this page and find an appropriate version for your platform. Once you open it, you will see a page like this:

To start using Docker, we must create a Docker ID as well. We can do so by a link provided in the same dialog box. Proceed to the next section once you have created an ID and logged into this instance. You should be able to configure Docker with this settings page when it starts:

Of course, we are using Mac and so, screenshots are specific to them and they can differ slightly based on your platform.

If you want to confirm that the Docker installation was correctly done, try running this command:

docker run hello-world

You will see following output:

Now that is running fine, we can move on to installing and using Redis from Docker Hub.

Install Redis from Docker Hub

Running a Redis instance using Docker Hub is actually just a matter of some commands and understanding the logic behind it. Fortunately, we will provide both of them here.

To pull a Redis Docker file and run it on local machine on the default port, i.e. 6379, run the following command:

docker run –name some-redis -d redis

When you run the above command in terminal, you will see that it starts downloading the necessary files:

Let’s wait for the download to complete. Depending on the latest available file size, this can take up to few minutes.

Once this is done, open another tab for your terminal try running this command:

docker ps

The output will be:

So, our redis server is now running and ready to be queried upon!

Binding Redis to Local port

If you want one of your application to bind to the Redis server we just started, it won’t be able to do so as of now.

Just run the following command to make it available in a local port as well:

docker run -p 6379:6379 redis

Just note that the Redis image will not be downloaded again. It will only be checked if a more recent version is available locally than current version.

Trying Redis

Now, we will check running Redis and interacting with it. Run Redis using above command and you will see something like:

Once you see that Redis is now accepting connections, we can try interact it at the port we specified, which is 6379.

We can enter into the Redis CLI with the following command:

redis-cli

*) Note: if you are running on linux first install redis-tools package

When run, we will see the following result:

We will only try saving some data here. Let’s try one last command:

That’s it. This means we were able to save data into the Docker running container image of Redis, awesome!

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

A Beginner’s Guide To Docker Compose

Docker Compose is one of the most useful tools for Software Developers and System Administrators. Many jobs require someone...
29/12/2020

How to List Docker Images

Docker is an open source containerization system. Docker images are basically a base layout from which containers are created....
29/12/2020

Using Docker Volumes to Share Data Between Containers and Host Computer

Docker volumes are used to persist data from a certain directory or directories of your Docker containers. So your data...
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Dịch Vụ Xây Dựng Hệ Thống Peering Với Internet Exchange (IXP)
04/04/2025

Dịch Vụ Triển Khai VPN Site-to-Site & Remote Access
04/04/2025

Dịch Vụ Thiết Lập Hệ Thống Tường Lửa (Firewall)
04/04/2025

Dịch Vụ Triển Khai Hệ Thống Ảo Hóa & Cloud
04/04/2025

Dịch Vụ Triển Khai Hệ Thống Ceph
04/04/2025