Docker安装redis挂载持久化及IPv4 forwarding is disabled. Networking will not work. 报错解决办法

一、安装redis

1. 拉取最新版的 Redis 镜像

docker pull redis

2. 创建目录并进行挂载

mkdir -p /mydata/redis/conf
touch /mydata/redis/conf/redis.conf

docker run -p 6379:6379 --name redis -v /mydata/redis/data:/data \
-v/mydata/redis/conf/redis.conf:/etc/redis/redis.conf \
-d redis redis-server /etc/redis/redis.conf

3. 开启redis的AOF持久化

cd /mydata/redis/conf/

vi redis.conf

appendonly yes

在这里插入图片描述

二、Docker启动WARNING:IPv4 forwarding is disabled. Networking will not work. 报错解决办法

vi /etc/sysctl.conf

net.ipv4.ip_forward=1  #添加这段代码

#重启network服务

systemctl restart network && systemctl restart docker

#查看是否修改成功 (返回1,就是成功)

[root@docker-node2 ~]# sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1

觉得不错的小伙伴可以点赞关注和收藏哦!
博主更多博客

猜你喜欢

转载自blog.csdn.net/llllllkkkkkooooo/article/details/106198344