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

How to Remove All Docker Images

Docker keeps a local copy of every Docker image you download. So, your Docker host may get congested at some point. All...
29/12/2020

How to Run Consul Server using Docker

Consul is an open-source service discovery tool which is based and built on Golang. It helps you discovering services application...
29/12/2020

Install Redis From Docker Hub

Overview In this post, we will see how we can install and use Redis server from  Docker Hub. Using Docker Hub is very...
28/12/2020
Bài Viết

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

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1
28/05/2024

Thuê địa chỉ IPv4 IPv6 trọn gói ở đâu chất lượng, giá RẺ nhất?
27/05/2024