Get the App
SLTechnology News&Howtos  ›  Development  › 

How Docker installs and configures Redis images

Shulou Source: shulou.com Published: 2022-06-02 11:54:46 10月18日 Update

This article mainly introduces Docker how to install and configure Redis image. The article is very detailed and has certain reference value. Interested friends must read it!

preface

How to install Redis image, create Redis container and map port mount data volumes and configuration data.

environment

CentOS 7

Docker 20.10.10

installation

pull images from the nearest region

docker pull redis

view the image

docker images

Create and start MySQL container

Create data directories and profiles

Create Configuration Folder

mkdir -p /mydata/redis/conf

create a profile

The requested URL/conf/redis/was not found on this server.

Create the redis.conf configuration file in advance, because when you mount the local/mydata/redis/conf/redis.conf to/etc/redis/redis.conf, the last redis.conf in the path will not be regarded as a file, but as a directory. Therefore, if we want to mount the local configuration file redis.conf to Docker container, we need to create the configuration file in advance.

#######################################

Complete the steps above to create a data directory and configuration file ~

#######################################

Create and start 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

-p 3306:3306: Map port 6379 of container to port 6379 of host

--name redis: defines 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, start with redis image according to the configuration file/etc/redis/redis.conf later

View running containers docker ps

Redisdocker exec -it redis redis-cli connected to Docker

stored-value

set name zhangsan

value

get name

Set up Redis persistent storage

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

echo "appendonly yes" >> /mydata/redis/conf/redis.conf The above is "Docker how to install and configure Redis image" All the contents of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

Tags: Configuration file data container image host folder directory port content article built native run value interest memory preface parameter name Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Microsoft NVidia MySQL Shulou Technology