How to install redis5.0.3 in docker

How to install redis5.0.3 in docker

1. Pull the official 5.0.3 image

[root@localhost ~]# docker pull redis:5.0.3

Download Complete

[root@localhost ~]# docker pull redis:5.0.3
5.0.3: Pulling from library/redis
f7e2b70d04ae: Pull complete 
421427137c28: Pull complete 
4af7ef63ef0f: Pull complete 
b858087b3517: Pull completed 
2aaf1944f5eb: Pull complete 
8270b5c7b90d: Pull complete 
Digest: sha256:4be7fdb131e76a6c6231e820c60b8b12938cf1ff3d437da4871b9b2440f4e385
Status: Downloaded newer image for redis:5.0.3

2. Create a mount directory

1. Create a mount folder

[root@localhost ~]# mkdir -p /root/redis/data /root/redis/conf
[root@localhost ~]# cd redis/
[root@localhost redis]# ls
conf data

2. Create redis.conf

Create the file redis.conf in the /root/redis/conf directory

touch redis.conf

Show Catalog

[root@localhost redis]# cd conf/
[root@localhost conf]# ls
[root@localhost conf]# touch redis.conf
[root@localhost conf]# ls
redis.conf
[root@localhost conf]#

3. Create a redis container

docker run -d --name redis -p 6379:6379 -v /root/redis/conf/redis.conf:/redis.conf -v /root/redis/data:/data redis:5.0.3 redis-server --appendonly yes

Parameter Description:

-d Run in the background

-p port mapping to the host port

-v mounts the host directory to the container's directory

redis-server --appendonly yes : Execute the redis-server startup command in the container and turn on the redis persistence configuration

1. Start redis

The error reported during startup is as follows:

[root@localhost ~]# docker run -d --name redis -p 6379:6379 -v /root/redis/conf/redis.conf:/redis.conf -v /root/redis/data:/data redis:5.0.3 redis-server --appendonly yes
9bc537c19ff0ad76727b5215da8cba4223c5ff97f1d9a53585d573ca71fd8c0c
docker: Error response from daemon: driver failed programming external connectivity on endpoint redis (fa297144f8d0c958288bb35a94ffbec545d348f2ff9f55a5b573f3d9a0354ace): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 6379 -j DNAT --to-destination 172.17.0.3:6379 ! -i docker0: iptables: No chain/target/match by that name.
 (exit status 1)).

Note: The custom chain DOCKER defined when the docker service is started is cleared for some reason. Restart the docker service and regenerate the custom chain DOCKER

Solution:

Step 1. Restart Docker.

Step 2: Start the container;

systemctl restart docker
docker start foo

2. The container is created successfully and the redis container is started

docker start redis

1. Startup failure problem: When starting the container, an error message appears: iptables: No chain/target/match by that name

The rough solution is to restart Docker

2. Normal startup and display

4. Client connection

I use RedisDesktopManager


The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of installing redis in docker and starting it as a configuration file
  • Docker installs Redis and introduces the visual client for operation
  • Docker installs redis 5.0.7 and mounts external configuration and data issues
  • How to deploy redis in linux environment and install it in docker
  • Docker installs the official Redis image and enables password authentication
  • 5 minutes to teach you how to install and start redis in docker (new method)

<<:  Full steps to create a password generator using Node.js

>>:  Various problems encountered by novices when installing mysql into docker

Recommend

Summary of JavaScript JSON.stringify() usage

Table of contents 1. Usage 1. Basic usage 2. The ...

CSS to achieve zoom in and out close button (example code)

This effect is most common on our browser page. L...

Vue implements the method example of tab routing switching component

Preface This article introduces the use of vue-ro...

Vue implements multi-column layout drag

This article shares the specific code of Vue to i...

How to lock a virtual console session on Linux

When you are working on a shared system, you prob...

Application examples of WeChat applet virtual list

Table of contents Preface What is a virtual list?...

Summary of common functions of PostgreSQL regular expressions

Summary of common functions of PostgreSQL regular...

Linux kernel device driver address mapping notes

#include <asm/io.h> #define ioremap(cookie,...

Mysql uses insert to insert multiple records to add data in batches

If you want to insert 5 records into table1, the ...

How to install Jenkins on CentOS 8

To install Jenkins on CentOS 8, you need to use t...

Steps to split and compress CSS with webpack and import it with link

Let's take a look at the code file structure ...

Web Design Tutorial (7): Improving Web Design Efficiency

<br />Previous article: Web Design Tutorial ...

How much data can be stored in a MySQL table?

Programmers must deal with MySQL a lot, and it ca...

How to change the host name in Linux

1. View the current host name [root@fangjian ~]# ...