下载镜像、创建网桥
docker pull redis:6.2.7
docker network create --driver bridge --subnet 172.18.0.0/16 --gateway 172.18.0.1 chirpstack-docker_default
修改配置
配置文件:redis.conf
#bind 127.0.0.1
protected-mode no # 默认yes,如果设置为yes,则只允许在本机的回环连接,其他机器无法连接。
daemonize no # 默认yes,意为是否以守护进程方式启动,可后台运行,不要yes 否则可能redis会启动失败
appendonly yes
#logfile /var/log/redis/redis-server.log
#dir /var/lib/redis
创建容器
mkdir -p /data/docker/redis/{conf,data}
chown -R 999:999 /data/docker/redis
docker run --detach \
--name redis \
--hostname redis \
--net chirpstack-docker_default \
--ip 172.18.0.3 \
--restart always \
--privileged=true \
-v /data/docker/redis/conf:/etc/redis \
-v /data/docker/redis/data:/data \
-v /etc/localtime:/etc/localtime:ro \
redis:6.2.7 \
redis-server /etc/redis/redis.conf
docker logs -f redis
docker exec -it redis /bin/bash
额外用到的
docker network inspect chirpstack-docker_default
docker network connect chirpstack-docker_default chirpstack-docker_default
|