Use the official redis image to build the database service. The current latest version corresponds to version 5.0.8. Mount local data directories, configuration directories, and log directories to facilitate data backup and migration. 1 Create mount directories and filesCreate a configuration directory ~/docker/redis/conf, a data directory ~/docker/redis/data, and a log directory ~/docker/redis/log on the host, and create a file ~/docker/redis/conf/redis.conf in the configuration directory. The contents of the configuration file are as follows. logfile /log/redis.log The final directory structure is as follows: 2 Pull the redis imageUse the latest official version of redis image, currently version 5.0.8. docker pull redis 3 Create a container and start itMount local configuration, data, and log directories into the container. # --name redis The container name is redis # -p 6379:6379 binds local port 6379 to container port 6379 (redis service port) conf:/usr/local/etc/redis/redis.conf -v ~/docker/redis/log/:/log/ -v ~/docker/redis/data:/data -d redis redis-server /usr/local/etc/redis/redis.conf --appendonly yes After the container is started, you can view the redis operation status through the local ~/docker/redis/log/redis.log. 4 Redis usageUse the local redis-cli client to connect to redis and add the key value v=1. After performing several operations, the appendonly.aof file in the ~/docker/redis/data directory already has relevant data content. 5 Simulating the effect of data migrationIf you stop the redis container at this time and start a new redis container to mount the same directory, the redis in the new container will already contain the data in the previous container. docker run --name redis1 -p 6379:6379 -v ~/docker/redis/conf/redis.conf:/usr/local/etc/redis/redis.conf -v ~/docker/redis/log/:/log/ -v ~/docker/redis/data:/data -d redis redis-server /usr/local/etc/redis/redis.conf --appendonly yes If you need more customized configuration, you can add it in the local ~/docker/redis/conf/redis.conf file Refer to the official redis image The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Solution to the img tag problem below IE10
>>: How to position the header at the top using CSS sticky layout
The MERGE storage engine treats a group of MyISAM...
async function and await keyword in JS function h...
In applications with paging queries, queries that...
The table creation command requires: The name of...
When I was at work today, the business side asked...
This article example shares the specific code of ...
Table of contents Preface What situations can cau...
Several common paging methods: 1. Escalator metho...
Keepalived+Nginx+Tomcat to achieve high availabil...
Preface Recently, our company has configured mbp,...
Beginners can learn HTML by understanding some HT...
Basic Concepts Absolute positioning: An element b...
For a newly created website, take ASP.NET MVC5 as...
This article uses an example to describe how to q...
Transactional Characteristics 1. Atomicity: After...