This article implements the function to solve the redis container starts when the redis.conf starts and the failure simply understands the redis.conf some configuration understanding the docker run command parameters
@TOC
Learn the configuration file redis.conf
When you open redis.conf, you will see a lot of useless information
Command the cat redis. Conf | grep -v “#” | grep -v “^ $”
Execute the command: cat redis. Conf | grep -v “#” | grep -v “^ $” – > redis – test. Conf
- Daemonize no: Redis is not used as a daemon by default, which is why starting redis with redis-server /redis/redis.conf without modifying the configuration file will display a service directly, and you will not be able to operate other services from the terminal. Only one new terminal can be opened to connect to Redis
- Requirepass Foobared: Redis has no password connection by default, but it still needs to be set for security
- Bind 127.0.0.1: This configuration item is usually commented out directly. When this configuration is enabled, only local users can connect to Redis
The above configuration information is all you need to know for this article
Understand the parameters of the docker run command
The docker run command creates a new container
The following is a command I create containers use docker run – itd – restart = “always” – the name of 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: Opens STDIN for console interaction
- T: Assigns a tty device, which can support terminal login. Default is false
- D: specifies whether the container is running in the foreground or the background. Default is false
- V: mounts a volume to a directory in the container
- –net: The container uses its own custom network
- -p: indicates the port number
- No: do not restart the container when the container exits. On-failure: Restart the container when the container exits due to a fault. Always: Restart the container when the container exits
The redis container fails to start the redis.conf file
Conf and docker run. This is the first time that a docker run has failed to start with redis.conf.
WARNING: IPv4 Forwarding is disabled. Networking will not work.
vim /usr/lib/sysctl.d/00-system.conf
net.ipv4.ip_forward=1
systemctl restart network
There will be no problem in the implementation
Redis.conf has a daemonize no parameter that specifies whether the daemonize is executed by a daemon. During development, we set this parameter to yes.
Then recall that docker run has a parameter -d which is also executed by the daemon.
Redis.conf conflicts with the docker configuration
Open the configuration file and change the daemon to no
docker exec -it redis /bin/bash