Home > Database > Redis > Solve the problem of failure to start the Redis container using redis.conf

Solve the problem of failure to start the Redis container using redis.conf

咔咔
Release: 2020-05-21 13:11:54
Original
3775 people have browsed it

The functions implemented in this article

Resolve the startup and failure of the redis container when starting redis.conf

Brief understanding of some configurations of redis.conf

Understanding Parameters of the docker run command

Understand the configuration file of redis.conf

You will see a lot of useless information after opening redis.conf

Solve the problem of failure to start the Redis container using redis.conf

We use the grep command to simply process it, and then you can see all the configuration information of redis.conf, but the command entered now cannot be edited

Execute the command: cat redis.conf | grep -v "#" | grep -v "^$"

Solve the problem of failure to start the Redis container using redis.conf

Although the above will get all the configuration information of redis.conf It comes out, but it cannot be modified. We can output this content to another file. At this time, you can see a redis-test.conf file under redis.

Execute the command: cat redis. conf | grep -v "#" | grep -v "^$" ->redis-test.conf

Solve the problem of failure to start the Redis container using redis.conf

At this time, it can be in redis-test.conf Modify some configuration information

Solve the problem of failure to start the Redis container using redis.conf

#Here we first understand a few configurations, and the subsequent configurations will be written out sequentially in subsequent files

  • daemonize no: redis is not used as a daemon process by default, which is why if you use redis-server /redis/redis.conf directly without modifying the configuration file, starting redis will directly display a service. There is no way to operate this terminal. You can only open a new terminal to connect to redis

  • requirepass foobared: redis does not have a password to connect by default, but the password still needs to be set for security

  • bind 127.0.0.1: This configuration item is usually commented out directly. After this configuration is turned on, only the local machine can connect to redis

The above The configuration information is the three configuration information you need to know in this article

Understand the docker run command parameter information

The docker run command is to create a new container

The following It is a command I use to create a container `docker run -itd --restart="always" --name redis -v /usr/local/docker/data:/data -v /usr/local/docker/redis.conf: /etc/redis.conf --net mynetwork -p 6380:6379 --ip 172.10.0.2 redis:4.0 redis-server /etc/redis.conf`

  • i : Open STDIN , used for console interaction

  • t: Allocate tty devices, which can support terminal login, the default is false

  • d: Specify the container to run Whether in the foreground or the background, the default is false

  • v: Mount the storage volume to the container and mount it to a directory in the container

  • - -net: The container uses its own customized network

  • -p: It is the port number

  • --restart: Specifies the restart after the container is stopped. Policy no: Do ​​not restart when the container exits on-failure: Restart when the container fails to exit (return value is non-zero) always: Always restart when the container exits

Solution to redis container startup redis.conf Time-based startup and failure

After we know several parameters of redis.conf and several common parameters of docker run, we will solve the problem of direct failure when using redis.conf to start.

Then start creating the container. Some partners will find an error `WARNING: IPv4 forwarding is disabled. Networking will not work.`

Solve the problem of failure to start the Redis container using redis.conf

Let’s solve it first This problem

Execute the command `vim /usr/lib/sysctl.d/00-system.conf`

Add the following code `net.ipv4.ip_forward=1`

Restart the network command `systemctl restart network`

There will be no problem if you execute it

Solve the problem of failure to start the Redis container using redis.conf

Then enter the container and you will find our problem , exited directly after creating the container

Solve the problem of failure to start the Redis container using redis.conf

Are you very depressed at this time, why did you exit directly. This is why in the above, we proposed some configuration information of redis.conf and docker run command parameters.

At this time, we are reviewing whether there is a `daemonize no` in redis.conf. This parameter is whether to execute as a daemon process. During the development process, we will turn on this configuration and configure it to yes.

Then let’s review that there is a parameter `-d` in the docker run command. This parameter is also executed as a daemon process.

It should be clear now that redis.conf conflicts with docker configuration

Open the configuration file and change the daemon process to no

Solve the problem of failure to start the Redis container using redis.conf

#Then delete the redis container just created, execute the above command here, you can see that the container has now been created Successful and in the open state

Solve the problem of failure to start the Redis container using redis.confAt this time, when entering the container `docker exec -it redis /bin/bash`, you can see that we need to enter a password when connecting to redis-cli, which is also It is configured in redis.conf.

Solve the problem of failure to start the Redis container using redis.conf

The above is Kaka’s solution to solve the problem of failure to start the Redis container using redis.conf

The above is the detailed content of Solve the problem of failure to start the Redis container using redis.conf. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template