The installation

# docker pull redis


Using default tag: latest
latest: Pulling from library/redis
6ec7b7d162b2: Already exists 
1f81a70aa4c8: Pull complete 
968aa38ff012: Pull complete 
884c313d5b0b: Pull complete 
6e858785fea5: Pull complete 
78bcc34f027b: Pull complete 
Digest: sha256:0f724af268d0d3f5fb1d6b33fc22127ba5cbca2d58523b286ed3122db0dc5381
Status: Downloaded newer image for redis:latest
docker.io/library/redis:latest

Copy the code

To view

# docker images REPOSITORY TAG IMAGE ID CREATED SIZE portainer/portainer-ce latest 980323c8eb3f 27 hours ago 196MB mysql 5.7.32 F07dFA83b527 2 weeks ago diver/ Docker-oracle-XE-11g latest f07dFA83b527 3 weeks ago diver/ Docker-oracle-XE-11g latest 396b3e06a5DC 5 Years ago 2.7GBCopy the code

run

# docker run -itd -p 6379:6379 --name redis6 redis --requirepass '123456'

e2daf821c5ef2cd0519e1607be71741d789417a737b3f873d43591150a7f8552
Copy the code

-I: Runs the container in interactive mode, usually in conjunction with -t

-t: reassigns a pseudo-input terminal to the container. It is usually used together with -i

-d: Runs the container in the background and returns the container ID

-p: specifies the port mapping. The format is host (host) port: container port

-name: specifies a name for the container :redis6

Redis: mirror

–requirepass: Configure password (123456)

View the Redis container in action

# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e2Daf821C5ef redis "docker-entryPoint.s..." 4 minutes ago Up 4 minutes 0.0.0.0:6379->6379/ TCP redis6Copy the code

See the log

# docker logs redis6 1:C 08 Jan 2021 09:18:47.741 # oO0OoO0OoO0Oo Redis is starting OO0ooo0ooo0ooo0oo 1:C 08 Jan 2021 09:18:47.742 # Redis version=6.0.9, bits=64, commit=00000000, modified=0, pid=1, Just started 1: Jan 08 2021 09:18:47. C # 742 Configuration. The loaded _ _ _. - ` ` __ '- _ _. - ` ` `. ` _.' '- _ Redis 6.0.9 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-... - ` __... -.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 1 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-'  |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 1:M 08 Jan 2021 09:18:47.745 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 1:M 08 Jan 2021 09:18:47.745 # Server Initialized 1:M 08 Jan 2021 09:18:47.745 # WARNING overcommit_memory is set to 0!  Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. 1:M 08 Jan 2021 09:18:47.745 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo madvise > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is Disabled (set to 'madvise' or 'never'). 1:M 08 Jan 2021 09:18:47.746 * Ready to accept connectionsCopy the code

Log in Redis – Client

# docker exec -it redis6 /bin/bash root@e2daf821c5ef:/data# root@e2daf821c5ef:/data# redis-cli 127.0.0.1:6379> # Enter the password 123456 127.0.0.1:6379> auth 123456 OKCopy the code