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
Table of contents Preface introduce 1. Mechanism ...
sshd SSH is the abbreviation of Secure Shell, whi...
This article shares the specific code of Bootstra...
Docker is really cool, especially because it'...
Table of contents 1. Clever use of indexes and va...
In the past few years, I have been moving back an...
Table of contents Precautions Necessary condition...
1. Introduction This article does not have screen...
This question is very strange, so I will go strai...
@vue+echarts realizes the flow effect of China ma...
Frequently asked questions Access denied for user...
It is troublesome to install the db2 database dir...
The link-in style is to put all the styles in one...
In MySQL, you can use the SQL statement rename ta...
This article shares the specific code of jQuery t...