拉取镜像
docker pull redis:latest
启动并设置密码、开启持久化
docker run -d --name redis-server -p 6379:6379 redis:latest --requirepass "yourpassword" --appendonly yes
查看redis
# 查看container
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e2a35e7cd6ae rabbitmq "docker-entrypoint..." 7 minutes ago Up 7 minutes 4369/tcp, 0.0.0
# 进入redis-cli, -a 表示设置的密码 -it后面是 CONTAINER ID
docker exec -it e2a35e7cd6ae redis-cli -a "yourpassword"
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379>