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

Dockerfile Volumes

When you run a Docker container, none of the data in that container is saved. What I mean is, let’s say you started a...
29/12/2020

Setting Up Your Own Docker Image Repository

Setting up your own private Docker image repository is very important for many reasons. With your private Docker image...
29/12/2020

Using Dockerfile to Expose Ports

It is really easy to create a custom Docker image from existing Docker images using Dockerfile. Usually people uses a minimal...
29/12/2020
Bài Viết

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

Mua proxy v4 chạy socks5 để chơi game an toàn, tốc độ cao ở đâu?
18/05/2024

Thuê mua proxy Telegram trọn gói, tốc độ cao, giá siêu hời
18/05/2024

Thuê mua proxy Viettel ở đâu uy tín, chất lượng và giá tốt? 
14/05/2024

Dịch vụ thuê mua proxy US UK uy tín, chất lượng số #1
13/05/2024

Thuê mua proxy Việt Nam: Báo giá & các thông tin MỚI NHẤT
13/05/2024