Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the steps for docker container deployment of redis

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "what is the docker container deployment redis step". In the daily operation, I believe that many people have doubts about what the docker container deployment redis step is. The editor consulted all kinds of information and sorted out a simple and easy-to-use operation method. I hope it will be helpful to answer the question of "what is the docker container deployment redis step?" Next, please follow the editor to study!

1 redis Profil

Official download: redis.conf

Path: in the container, you can generally save it in the / etc/redis/redis.conf path

Explain the configuration file in detail and modify it according to the actual situation:

# the bind here means that only the specified network segment can access the redis. There is no such restriction after comments. "the default port is 6379port 637 daemonize, which means whether to execute as a daemon. Execution in the container must be set to yes in the no# container. If it is set to yes, it will conflict with the-d in the docker run, resulting in startup failure. Daemonize no# protected-mode # set to yes means to enable the protection mode. No remote access # indicates protected mode if it is set to no, and if protected-mode no# is commented out, the default redis password is empty # enabled, then redis123 sets the number of databases for reids login password requirepass redis123# databases, databases "savesave 900 1save 300 10save 60 1000" does not turn on aof mode by default The default is rdb persistent appendonly yes # to yes enable aof function appendfilename "appendonly.aof" # persistent file name # appendfsync always # each modification will sync, consumption performance appendfsync everysec # execute sync once per second, may lose this 1s of data # appendfsync no # do not execute sync, the operating system will automatically synchronize data 2 docker command to start

Start command

Docker run-p 6379Users/chenbinhao/redis_6379/config/redis.conf:/etc/redis/redis.conf 6379\-v / Users/chenbinhao/redis_6379/data:/data\-v / Users/chenbinhao/redis_6379/config/redis.conf:/etc/redis/redis.conf\-d redis redis-server / etc/redis/redis.conf-- appendonly yes

Parameter description

-p port mapping, redis default port is 6379

-v mainly maps files in two paths

The data is saved in the path in the / data redis container, and it is mapped here to persist the data.

/ etc/redis/redis.conf the location where the custom configuration file is saved, which is mapped so that the custom configuration file can be specified at startup.

-d means to run as a daemon in the background. Note: daemonize no needs to be configured in the redis.conf configuration file, otherwise it will not be able to start successfully.

Redis-server / etc/redis/redis.conf-- appendonly yes starts the redis command, which is required if started with a custom configuration file.

Log view: if docker logs containerID fails to start, use this command to view the failure log and debug according to the log

3 docker-compose start

Directory structure

├─ reids_6379 │ ├─ docker-compose.yml │ ├─ config │ │ └─ redis.conf │ └─ data │ │ └─..

Configure the docker-compose.yml file

Version: '3'services: redis: image: redis:latest restart: always ports:-"6379 image 6379" volumes:-". / data:/data"-". / config/redis.conf:/etc/redis/redis.conf" command: redis-server / etc/redis/redis.conf

Start command

Startup: execute docker-compse up-d in the same directory as docker-compose.yml

Stop and delete: docker-compose down

At this point, the study on "what is the step of deploying redis in docker container" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report