Update: Recently, it was discovered that the server was hacked by a mining virus, most likely because redis did not set a password! 1. Get the redis imagedocker pull redis Specify the version number: docker pull redis:4.0.9 Without adding a version number, the latest version is obtained by default. You can also use docker search redis to view the image source 2. View local imagedocker images 3. Then start the container and do the mapping①Create a configuration file directory to store redis.conf. Download the file from the official website . ②Create a folder, create a new configuration file, paste the configuration file downloaded from the official website and modify it mkdir /usr/local/docker vi /usr/local/docker/redis.conf ③Modify the startup default configuration (from top to bottom): bind 127.0.0.1 #Comment this part out to limit redis to local access only protected-mode no #Default is yes, turn on protected mode and limit access to local devices daemonize no #Default is no. Changing to yes means starting redis as a daemon process. It can run in the background unless the process is killed. Changing to yes will cause the configuration file to start redis to fail. databases 16 #Number of databases (optional). I changed this just to see if it works. . dir ./ #Enter the local redis database storage folder (optional) appendonly yes #redis persistence (optional) 4.docker starts redis commanddocker run -p 6379:6379 --name myredis -v /usr/local/docker/redis.conf:/etc/redis/redis.conf -v /usr/local/docker/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes Command explanation: -p 6379:6379 port mapping: the part before represents the host part, and the part after represents the container part. --name myredis specifies the container name, which is convenient for viewing and operating . -v mount directory, the rules are the same as port mapping. Why do we need to mount the directory: I personally think that Docker is a sandbox isolation-level container. This is its characteristic and security mechanism. It cannot access external (host) resource directories at will, so this mounting directory mechanism is needed. -d redis means starting redis in the background redis-server /etc/redis/redis.conf starts redis with the configuration file, loads the conf file in the container, and finally finds the mounted directory /usr/local/docker/redis.conf --appendonly yes enables redis persistence 5. Check whether the operation is successfuldocker ps View running containers docker logs myredis/27ddba64faa6 (container name/id) Docker basic commands: View all docker images Delete the image (will prompt to stop the container in use first) docker rmi image name/image id View all containers docker ps -a View the container running log docker logs container name/container id Stop the container and run docker stop container name/container id After terminating the container, run docker start container name/container id Container restart docker restart container name/container id Delete container docker rm container name/container id This is the end of this article about installing redis in docker and starting it with a configuration file. For more information about installing redis in docker and starting it, 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:
|
<<: The solution to the problem that the web table or div layer is stretched in the web page
>>: Example of using CSS to achieve semi-transparent background and opaque text
This article introduces the CSS Sticky Footer imp...
Six steps to install MySQL (only the installation...
Introduction: This article mainly introduces how ...
This article shares the specific code of the WeCh...
This article uses an example to describe how to c...
Sysbench is an excellent benchmark tool that can ...
System performance expert Brendan D. Gregg update...
In actual development, the primary key of MySQL c...
Not only does it reduce the cost of website develo...
Table of contents Primary key index Create indexe...
question In LINUX, periodic tasks are usually han...
Preface <br />I have been working in the fro...
Table of contents background What are the methods...
Add the following code to the CSS style of the el...
Table of contents 1. Process Control 2. Sequentia...