Deploy redis in docker First install Docker in Linux, then start the Docker service Start Docker in Centos7 systemctl start docker //Start docker systemctl stop docker //Stop docker systemctl restart docker //Restart docker Find the image you want to pull 1. Use docker search image name to search for the image directly in Linux Pull the image using docker pull image name docker pull redis //Do not specify a version number, pull the latest one by default. docker pull redis:6.0.8 After pulling the image, use docker images to view the pulled image docker images docker rmi image ID //delete the image Configure redis before running The redis.conf configuration file can be downloaded at http://download.redis.io/redis-stable/redis.conf Use mkdir /usr/local/docker to create a docker directory on the host machine. vi /usr/local/docker/redis.conf to create the redis configuration file redis.conf in docker. Replace the downloaded redis.conf file or copy the content to the configuration file you created and then modify the configuration bind 127.0.0.1 //127.0.0.1 restricts access to the local machine only and changes it to 0.0.0.0 protected-mode no # The default is yes, which turns on protected mode and limits access to local devices daemonize no The default is no, and changing to yes means starting redis as a daemon process. Yes will cause the configuration file to fail to start redis (it will exit as soon as it is turned on) Run the specified image 1. $ docker run -itd --name redis-test -p 6379:6379 redis 2. $ docker run -itd -p 192.168.220.129:6379:6379 --name redis -v /usr/local/docker/redis.conf:/etc/redis/redis.conf -v /usr/local/docker/data:/data redis redis-server /etc/redis/redis.conf -d Run as a daemon thread (background run) -i runs the container in interactive mode -t reallocates a pseudo input terminal for the container -p maps port 6379 of the container service to port 6379 of the host machine. The outside world can directly access the Redis service through the host ip:6379. //It may not work without -it because, for Docker container to run in the background, there must be a foreground process. The commands run by the container are not those that are always suspended (such as running top, tail), and it will automatically exit -v /usr/local/docker/redis.conf:/etc/redis/redis.conf //Mount the redis.conf configured on the host to the specified location in the container -v /usr/local/docker/data:/data //Mount the persistent data of redis to the host for data backup redis-server /etc/redis/redis.conf //Start redis according to the configuration of redis.conf –appendonly yes //Data persistence after redis starts Operate the container after running 1. View the running container docker ps An error occurred Docker container port mapping error
Workaround
This is the end of this article about how to deploy and start redis in docker. For more information about deploying and starting redis in docker, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: JavaScript programming through Matlab centroid algorithm positioning learning
>>: HTML table markup tutorial (40): Dark border color attribute of the header BORDERCOLORDARK
Table of contents Preface 1. Install NJS module M...
Table of contents Index Model B+Tree Index select...
1. Enter the container docker run [option] image ...
Table of contents 1. Understanding the stack stru...
The problems and solutions encountered when insta...
Preface After MySQL version 3.23.44, InnoDB engin...
1. Download the mysql-5.7.17-winx64.zip installat...
<br />Based on the original width-and-height...
HTML <dl> Tag #Definition and Usage The <...
This tutorial shares the installation of mysql in...
Unique “About”-Pages A great way to distinguish yo...
Preface You may often receive warning emails from...
This article mainly introduces the detailed expla...
The image of the microservice will be uploaded to...
I struggled with this for a long time, and after s...