当前位置:网站首页>Docker installs redis and starts it as a configuration file
Docker installs redis and starts it as a configuration file
2022-07-23 17:54:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
——————————-
to update Recently, it was found that the server was invaded by mining virus It's probably because of redis Reason for not setting password !
——————————-
1. obtain redis Mirror image
docker pull redis
Specified version number :
docker pull redis:4.0.9
Get the latest version by default without adding the version number , You can also use docker search redis View image source
2. View local image
docker images
3. Then start the container , Mapping
① Create a profile directory to store redis.conf, File from the Download from the official website .
② Create folder , New profile is pasted into the profile downloaded from the official website and modified
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 out this part , This is the limit redis Locally accessible only
protected-mode no # Default yes, Turn on the protection mode , Limited to local access
daemonize no# Default no, Change it to yes Means to start as a daemons , Can run in the background , Unless kill process , Change it to yes Will cause profile mode to start redis Failure
databases 16 # Number of databases ( Optional ), I changed this just to see if it works ..
dir ./ # Input local redis Database storage folder ( Optional )
appendonly yes #redis Persistence ( Optional )
4.docker start-up redis command
docker 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 yesExplanation of order :
-p 6379:6379 Port mapping : The front represents the host part ,: After that is the container part .
–name myredis Specify the container name , It's convenient to check and operate .
-v Mount Directory , The rules are the same as port mapping .
Why do I need to mount the directory : Personally think that docker It's a sandbox isolation level container , This is its characteristics and security mechanism , You can't access the outside ( host ) Resource directory , So you need this mechanism to mount the directory .
-d redis Indicates background start redis
redis-server /etc/redis/redis.conf Start with configuration file redis, Load the... In the container conf file , Finally, we found the directory of the mount /usr/local/docker/redis.conf
–appendonly yes Turn on redis Persistence
5. Check to see if it runs successfully
docker ps View the running container
docker logs myredis/27ddba64faa6 ( Container name /id)
docker Basic commands :
View all mirrors docker images
delete mirror ( You will be prompted to stop the container in use first ) docker rmi Mirror image name/ Mirror image id
View all containers docker ps -a
View the container run log docker logs Container name / Containers id
Stop the container docker stop Containers name/ Containers id
Run after terminating the container docker start Containers name/ Containers id
Container restart docker restart Containers name/ Containers id
Delete container docker rm Containers name/ Containers id
Finally, I recommend an open source client connection tool
https://github.com/qishibo/AnotherRedisDesktopManager/releases
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/126567.html Link to the original text :https://javaforall.cn
边栏推荐
猜你喜欢

别再问我MySQL为啥没走索引?就这几种原因,全都告诉你

TwinCAT 3 首次运行报错4115

Trust counts the number of occurrences of words in the file

Time series data in industrial Internet of things

一次线上频繁FullGC的排查

Research and implementation of network multi exit design based on policy routing deployment

Leetcode skimming: dynamic programming 05 (different paths II)

From 5 seconds to 1 second, remember the performance optimization with "very" significant effect once

Keras之二分类问题

ContextLoaderListener vs DispatcherServlet
随机推荐
[JS] check whether the date object is invalid date
Solutions to sap Hana database backup failure
SAP HANA数据库备份失败解决办法
Rust中的dyn关键字
mysqldump的各项参数
[pytorch] basic use 7. GPU allocation
idea debug常用操作
MySQL7种JOIN(图)
网页返回更新
面试官:MySQL 数据库查询慢,除了索引问题还可能是什么原因?
From Markov chain to GPT, Li Hang, director of ByteDance AI Lab, detailed the past and present lives of language models
训练和测试的loss不下降,并且精度超低
rust求两数之和
Static distribution and dynamic distribution in trust
Paging class
ContextLoaderListener vs DispatcherServlet
一台Linux机器上启动多个redis实例
WARNING: Your password has expired.Password change required but no TTY available.
IDEA Download Sources报错 Connection refused的解决方法
Server environment setup