当前位置:网站首页>Docker install redis

Docker install redis

2022-06-26 09:04:00 aserendipper

1、 Search for Redis Mirror image , Or from Official website Query the required image in

docker search redis

2、 Select the image you want to download and pull it locally , The latest version image will be downloaded by default

docker pull redis

3、 because redis The default configuration can only connect locally , No remote access , So you need to mount it manually redis The configuration file , Create a new... On this computer data and conf Folders and redis Configuration file for

mkdir /docker/redis/data
mkdir /docker/redis/conf
cd /docker/redis/conf

vi redis.conf

# Comment out redis Can be accessed externally 
#bind 127.0.0.1 
# Start as a guard thread 
daemonize no
# Set the password 
requirepass 123456
#redis Turn on persistence 
appendonly yes
# Prevent the remote host from forcing an existing connection to close   Default 300
tcp-keepalive 300

4、 establish redis Container and start

docker run --name redis -p 6379:6379 -v /docker/redis/data:/data -v /docker/redis/conf/redis.conf:/etc/redis/redis.conf -d redis redis-server /etc/redis/redis.conf 
  • docker run: Run container
  • –name redis: Container name
  • -p 6379:6379: Will host the 6379 port ( Before colon ) Mapped to container 6379 port ( After the colon )
  • -v /docker/redis/data:/data: Will host the /docker/redis/data The directory is attached to the container's /data Catalog
  • -v /docker/redis/conf/redis.conf:/etc/redis/redis.conf: Will host the /docker/redis/conf/redis.conf The configuration file is attached to the container /etc/redis/redis.conf file
  • -d redis: Background program running redis
  • redis-server /etc/redis/redis.conf: Appoint redis Boot profile

5、 adopt docker ps Command view redis Startup successful
6、 Enter the container and connect redis

docker exec -it redis redis-cli -a 123456
原网站

版权声明
本文为[aserendipper]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206260838046400.html