docker安装redis
root@tr-desktop:/home/tr/redis# cat Dockerfile
# 使用官方 Redis 镜像作为基础镜像
FROM redis:latest
# 如果需要自定义配置,可以将本地配置文件复制到镜像中
# COPY redis.conf /usr/local/etc/redis/redis.conf
# 暴露 Redis 的端口(默认是 6379)
EXPOSE 6379
# 启动 Redis
CMD ["redis-server"]
root@tr-desktop:/home/tr/redis#
docker build -f /home/tr/redis/Dockerfile -t my-image .
docker run -d --name redis-container -p 6379:6379 redis --requirepass 123456
root@tr-desktop:/home/tr/redis# docker run -itd --name redis -p 6378:6379 redis
root@tr-desktop:/home/tr/redis# redis-cli -h 127.0.0.1 -p 6378
# 启动 Redis
CMD ["redis-server", "--requirepass", "123456"]