Docker installation and configuration steps for Redis image

Docker installation and configuration steps for Redis image

Preface

This tutorial demonstrates how to install the Redis image, create a Redis container, and map ports to mount data volumes and configuration data.

insert image description here

environment

  • CentOS 7
  • Docker 20.10.10

Install

Pull the image

docker pull redis

insert image description here

View Mirror

docker images

insert image description here

Create and start the MySQL container

Create data directories and configuration files

Create a configuration folder

mkdir -p /mydata/redis/conf

Create a configuration file

touch /mydata/redis/conf/redis.conf

Reminder to avoid pitfalls

Create the redis.conf configuration file in advance. Because when the local /mydata/redis/conf/redis.conf is mounted to /etc/redis/redis.conf , the last redis.conf in the path is not regarded as a file, but as a directory. Therefore, if we want to mount the configuration file redis.conf on the local machine into the Docker container, we need to create the configuration file in advance.
#######################################
Complete the above steps to create data directories and configuration files~
#######################################

Create and start the MySQL container command

sudo docker run -p 6379:6379 --name redis \
-v /mydata/redis/data:/data \
-v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf \
-d redis redis-server /etc/redis/redis.conf

Parameter Description

  • -p 3306:3306 : Map the container's port 6379 to the host's port 6379
  • --name redis : Define the container name as redis
  • -v /mydata/redis/data:/data : Mount the Redis data folder to the host
  • -v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf : Mount the Redis configuration folder to the host
  • -d redis redis-server /etc/redis/redis.conf : Run in the background and start with the redis image according to the following configuration file /etc/redis/redis.conf

insert image description here

View running containers

docker ps

insert image description here

Connecting to Redis in Docker

docker exec -it redis redis-cli

insert image description here

Store Value

set name zhangsan

insert image description here


Value

get name

insert image description here

Setting up Redis persistent storage

By default, redis data is stored in memory. After restart, the data is lost. After setting persistent storage, the data will still be in memory after restart.

echo "appendonly yes" >> /mydata/redis/conf/redis.conf

This is the end of this article about the implementation steps of Docker installation and configuration of Redis image. For more relevant content about Docker installation of Redis image, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Redis installation and configuration process in Windows and remote access function
  • Redis installation configuration and common commands
  • Redis basic knowledge, installation, deployment, and configuration notes
  • Installation and configuration method of Redis database
  • Detailed installation and configuration tutorial of Redis database

<<:  Summary of HTML horizontal and vertical centering issues

>>:  Introduction to JavaScript array deduplication and flattening functions

Recommend

Don’t bother with JavaScript if you can do it with CSS

Preface Any application that can be written in Ja...

Summary of MySQL5 green version installation under Windows (recommended)

1 Download MySQL Download address: http://downloa...

Detailed explanation of this pointing problem in JavaScript

Preface Believe me, as long as you remember the 7...

Using nginx + fastcgi to implement image recognition server

background A specific device is used to perform i...

MySQL sorting Chinese details and examples

Detailed explanation of MySQL sorting Chinese cha...

Common front-end JavaScript method encapsulation

Table of contents 1. Enter a value and return its...

Detailed explanation of html printing related operations and implementation

The principle is to call the window.print() metho...

JavaScript single thread and asynchronous details

Table of contents 1. Task Queue 2. To explain som...

Web Design Tutorial (5): Web Visual Design

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

Tutorial on upgrading, installing and configuring supervisor on centos6.5

Supervisor Introduction Supervisor is a client/se...

Linux directory switching implementation code example

Switching files is a common operation in Linux. W...

HTML insert image example (html add image)

Inserting images into HTML requires HTML tags to ...