The business requirements

Because companies need to deploy projects on Windows Server, projects need to use Redis. The prodigal son is ready to dry. When I went to redis official website to download Redis, I was dumbfounded! Redis is not available for Windows!! WTF!!! In desperation, the prodigal son searched the Internet and found an unofficial Redis. Here it is :github.com/MicrosoftAr… But this version is too low and has not been updated for a long time. Sad ~

Helpless, the prodigal son can only curve to save the country ~

Windows install Docker, and then install Redis on docker

Since Lu Xun has decided, let’s do it!

Windows installation docker

I have to say, Windows as a server, or a lot of inconvenience. At first, I used the official Windows documentation to install Docker, and it went smoothly. When the installation is complete and ready to install Redis…

No matching manifest for Windows/AMD64 10.0.17763 in the manifest list entries

This error basically means that Docker doesn’t match the Windows version. Collapse ~

Then I found a solution on the Internet, but…

But in the Docker I installed via Windows official documentation there is no whale icon at all wow. WTF!!!

Again, I had no choice but to download the installed version of Windows from the official website of Docker. Thanks God

Through the above way I went to download and install Redis when… Same mistake again. Oh, my god

I looked for a solution again in the morning and saw a configuration to modify the Docker download source, which I thought I would configure for faster download

{
  "registry-mirrors": [
    "https://registry.docker-cn.com",
    "http://hub-mirror.c.163.com",
    "https://docker.mirrors.ustc.edu.cn"
  ],
  "insecure-registries": [],
  "debug": false,
  "experimental": true,
  "features": {
    "buildkit": true
  }
}
Copy the code

And then when I went to install it again, it was right, hahahahaha

With that said, the following is a normal tutorial for Docker to install Redis

Docker installed redis

  1. Docker starts (starts
docker search redis
Copy the code

  1. Pull the Redis image
docker pull redis
Copy the code

Here I do not add redis version number, just pull the latest Redis image (no screenshot)

  1. View the Docker image
docker images
Copy the code

Here you can see that we have successfully pulled the Redis image

  1. Start the Redis image

Startup without configuration file

docker run -p 6379:6379 -d redis:latest redis-server
Copy the code

After this method is started, all the data is stored in the Docker. If the Docker is deleted, the data is lost. So production environments generally recommend that redis configuration and data be mapped locally. Here’s another way to start

  1. Download the redis.conf file from the official website

  2. Put redis.conf in a local directory, such as: D:/redis. And make some changes to the file:

Modify the default startup configuration (from top to bottom) :

Bind 127.0.0.1 # comment out this section, which will restrict redis to only local access. -mode no# default yes, enable the protected mode, restrict local access daemonize no# default no, 1. Database 16 # Database number (optional). I modified this file to check whether it works. Dir./ # enter the local redis database directory (optional) appendOnly yes # persistent redis (optional) requirePass password # Configure redis access passwordCopy the code
  1. Create a data directory under D:/redis to store redis data

  2. Start redis mirroring (configuration and data mapping to local)

docker run -d --name redis-server -p 6379:6379 -v D:/redis:/etc/redis -v D:/redis/data/:/data redis:latest /etc/redis/redis.conf --appendonly yes --requirepass "123456"
Copy the code

Ps: the first -v is to map redis. Conf to the redis configuration of docker. The second -v is to map the redis storage data. Here: the previous paths are local paths, don’t get me wrong

  1. View the Redis process
docker ps
Copy the code

  1. Use the Redis service through redis-CLI connection tests

Step 1: Connect to docker’s Redis image

Docker exec it redis-server /bin/bash Go to the docker terminal and enter redis-cliCopy the code

Ps: redis-server is the names of the docker ps command

Step 2: Connect to redis server (add the -a parameter if you have a password)

redis-cli -a 123456
Copy the code

At this point, our Redis is installed successfully. You can test the set GET data.

In this example, the name of the Docker container is redis. Run the docker logs -f -t –tail 100 redis command to view the logs

Prodigal son welcome everyone to exchange calculation wow ~ ha ha ha ha