[Docker] docker install redis

First, download the image and run the container

1. Specify redis.conf profile run

docker run -p 6379:6379 --name myredis -v $PWD/conf/redis.conf:/etc/redis/redis.conf -v $PWD/data:/data -d --restart=always  redis:5.0 redis-server /etc/redis/redis.conf --appendonly yes

2. do not specify a configuration file to run

docker run --name myredis -p 6379:6379 -v $PWD/data:/data  -d redis:5.0 redis-server --appendonly yes  --requirepass "123"

Command Description:
--restart = Always: start and start with docker

-p 6379: 6379: 6379 to map the container port to the host port 6379

-v $ PWD / data: / data: The data in the current directory is mounted to the main container / data

redis-server --appendonly yes: Start command in container execution redis-server, and open the redis persistence configuration

Guess you like

Origin www.cnblogs.com/756623607-zhang/p/11006867.html