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 Technology Stack Effect analyze...
1. Basic Concepts 1. Sitemesh is a page decoratio...
The code looks like this: // Line style of the pa...
In the process of team development, it is essenti...
Table of contents Preface Find the problem solve ...
What is a profile? We can use it when we want to ...
Table of contents introduction MySQL High Availab...
This article example shares the specific code of ...
Table of contents Main topic 1. Install Docker on...
Table of contents 1. First install echarts in the...
This article shares with you a graphic tutorial o...
Table of contents 1. Definition of stack 2. JS st...
Table of contents 1. Introduction: 2. The first i...
Preface In project development, there are many wa...
Style Sheets CSS (Cascading Style Sheets) is used...