Docker installs the official Redis image and enables password authentication

Docker installs the official Redis image and enables password authentication

Reference: Docker official redis documentation

1. If you have special version requirements, you can check the redis image tag version

3.2.11, 3.2, 3 (3.2/Dockerfile)
3.2.11-32bit, 3.2-32bit, 3-32bit (3.2/32bit/Dockerfile)
3.2.11-alpine, 3.2-alpine, 3-alpine (3.2/alpine/Dockerfile)
4.0.9, 4.0, 4, latest (4.0/Dockerfile)
4.0.9-32bit, 4.0-32bit, 4-32bit, 32bit (4.0/32bit/Dockerfile)
4.0.9-alpine, 4.0-alpine, 4-alpine, alpine (4.0/alpine/Dockerfile)

2. Select the latest version

docker pull redis:latest
[root@localhost~]# docker pull redis:latest
latest: Pulling from library/redis
4d0d76e05f3c: Pull complete 
cfbf30a55ec9: Pull complete 
82648e31640d: Pull complete 
fb7ace35d550: Pull complete 
497bf119bebf: Pull complete 
89340f6074da: Pull complete 
Digest: sha256:166788713c58c2db31c41de82bbe133560304c16c70e53a53ca3cfcf35467d8a
Status: Downloaded newer image for redis:latest

3. Start the container with a password

docker run --name redis-test -p 6379:6379 -d --restart=always redis:latest redis-server --appendonly yes --requirepass "your passwd"

-p 6379:6379 : Map the port in the container to the host port (the right side maps to the left side)
redis-server –appendonly yes: Execute the redis-server startup command in the container and turn on the redis persistence configuration
requirepass "your passwd": set the authentication password –restart=always: start when docker starts

4. View the container

docker ps
[root@localhost~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a126ec987cfe redis:latest "docker-entrypoint.s..." 4 minutes ago Up 4 minutes 0.0.0.0:6379->6379/tcp redis-test
3645da72ece6 portainer/portainer "/portainer" 7 days ago Up 7 days 0.0.0.0:9000->9000/tcp sharp_lovelace
118ba79de20a hwdsl2/ipsec-vpn-server "/opt/src/run.sh" 12 days ago Up 12 days 0.0.0.0:500->500/udp, 0.0.0.0:4500->4500/udp l2tp-vpn-server
848fdba6de60 kylemanna/openvpn "ovpn_run" 12 days ago Up 12 days 1194/udp, 0.0.0.0:1194->1194/tcp openvpn
a273504f9646 mysql:5.6.38 "docker-entrypoint.s..." 8 weeks ago Up 5 days 0.0.0.0:3306->3306/tcp mysql5.6.38

The id of the redis container is a126ec987cfe

5. Check the process

ps -ef|grep redis
[root@localhost~]# ps -ef|grep redis
polkitd 26547 26535 0 14:58 ? 00:00:00 redis-server *:6379
root 26610 26432 0 15:05 pts/0 00:00:00 grep --color=auto redis

6. Enter the container and execute the redis client

docker exec -it a126ec987cfe redis-cli -a 'your passwd'
[root@localhost~]# docker exec -it a126ec987cfe redis-cli -h 127.0.0.1 -p 6379 -a 'your passwd'
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>info
# Server
redis_version:4.0.9
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:d3ebfc7feabc1290
redis_mode:standalone
os:Linux 3.10.0-693.21.1.el7.x86_64 x86_64
...

-h 127.0.0.1 : The default is not added, which is -h 127.0.0.1
-p 6379: The default is not added, which is -p 6379

Or connect without a password, as follows:

[root@localhost ~]# docker exec -it a126ec987cfe redis-cli
127.0.0.1:6379> ping
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth 'your passwd'
OK
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>info
# Server
redis_version:4.0.9
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:d3ebfc7feabc1290
redis_mode:standalone
os:Linux 3.10.0-693.21.1.el7.x86_64 x86_64
arch_bits:64

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Docker deployment SpringBoot project integration Redis image for access counting sample code
  • How to create a redis image in docker
  • Implementation steps for installing Redis container in Docker
  • Teach you how to build Redis cluster mode and sentinel mode with docker in 5 minutes
  • How to build a redis cluster using docker
  • Docker builds Redis5.0 and mounts data
  • 5 minutes to teach you how to install and start redis in docker (new method)
  • Docker installation and configuration steps for Redis image

<<:  How to display texture at the position of swipe in CocosCreator

>>:  Detailed explanation of installing and completely uninstalling mysql with apt-get under Ubuntu

Recommend

Vue+webrtc (Tencent Cloud) practice of implementing live broadcast function

Table of contents 1. Live broadcast effect 2. Ste...

How to implement real-time polygon refraction with threejs

Table of contents Preface Step 1: Setup and front...

Button is stretched on both sides in IE

When you write buttons (input, button), you will f...

Detailed explanation of samba folder sharing server configuration under centos

1. Introduction Recently I found that there are m...

Why should css be placed in the head tag

Think about it: Why should css be placed in the h...

Install Mininet from source code on Ubuntu 16.04

Mininet Mininet is a lightweight software defined...

MySQL 8.0.20 winx64 installation and configuration method graphic tutorial

This article shares with you the installation and...

RGB color table collection

RGB color table color English name RGB 16 colors ...

Example to explain the size of MySQL statistics table

Counting the size of each table in each database ...

How to display div on object without being blocked by object animation

Today I made a menu button. When you move the mous...

VMware15.5 installation Ubuntu20.04 graphic tutorial

1. Preparation before installation 1. Download th...

How to use docker to deploy Django technology stack project

With the popularity and maturity of Docker, it ha...

How to solve the mysql insert garbled problem

Problem description: When inserting Chinese chara...

XHTML Getting Started Tutorial: Simple Web Page Creation

Create your first web page in one minute: Let'...

2 methods and precautions for adding scripts in HTML

How to add <script> script in HTML: 1. You c...