Docker install and start redis talk about the pits encountered in those years

Docker use tutorial related series catalog


table of Contents

Get redis.conf

Unzip to get redis.conf

Pit one:

Modify the configuration file redis.conf

Pit 2:

Create redis directory

Docker download, install and run redis

Start redis

Pit Three:

supplement:


Get redis.conf

Redis official website: https://redis.io/

Go to the official website, download the specified redis version , and unzip it to get redis.conf

Version 5.0.5 is used here

0

0

 

https://download.redis.io/releases/

Choose the version you want

0

Unzip to get redis.conf

0

Pit one:

The redis version obtained on the official website must be the same as the redis version installed by docker. The redis configuration files of different versions may be different.

Modify the configuration file redis.conf

Open redis verification requirepass 123456

0

Allow redis to connect to the outside world

#bind 127.0.0.1 要注释掉

0

Enable redis data persistence

appendonly yes

0

Pit 2:

This configuration will conflict with the -d parameter in dcoker run, causing the container to never start

daemonize yes 要注释

0

Create redis directory

cd /usr
mkdir redis

0

cd redis 

Put the prepared redis.conf into the reids directory

mkdir data

0

Docker download, install and run redis

Download the 5.0.5 version of redis

docker pull redis:5.0.5

0

docker images

Start redis

docker run -d -p 6379:6379 -v /usr/redis/redis.conf:/etc/redis/redis.conf -v /usr/redis/data:/data --name myredis redis:5.0.5 redis-server /etc/redis/redis.conf

0

Note: redis-server /etc/redis/redis.conf: specify the command executed when the container starts

If you don’t understand other commands, see my blog post about operating the container-->

Pit Three:

The container is created successfully, but it cannot run

0

Troubleshoot issues:

Look at the running log of redis

docker logs myredis

Error:

chown: changing ownership of '.': Permission denied

0

Insufficient permissions, the problem is found

solution:

Delete the redis container first

docker rm myredis

 

Add --privileged=true command

 

docker run -d -p 6379:6379 --privileged=true  -v /usr/redis/redis.conf:/etc/redis/redis.conf -v /usr/redis/data:/data --name myredis redis:5.0.5 redis-server /etc/redis/redis.conf

0

Enter the container

docker exec -it myredis /bin/bash

0

Execute redis-cli to connect to redis

Prompt no permission, indicating that our redis.conf configuration has taken effect

0

Enter the verification password:

0

Under the test, OK

0

0

supplement:

Redis can be connected directly outside the container

docker exec -it myredis redis-cli

0

If you have encountered other pits, you can also leave a message to express, give someone a rose, leave a fragrance in your hand

Guess you like

Origin blog.csdn.net/shi_hong_fei_hei/article/details/115361510