docker手动创建redis镜像

手动创建redis镜像

. |-- Dockerfile `-- redis.conf

redis.conf 文件从官方软件包里获取
这里只修改了运行远端访问:
bind 0.0.0.0 -::1#修改为0.0.0.0,使redis可以外部访问

Dockerfile:
FROM redis COPY redis.conf /usr/local/etc/redis/redis.conf CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ]

构建镜像myredis
docker build -t myredis .

通过myredis创建一个 redis01的容器
docker run -itd -p 16379:6379 --name redis01 myredis:latest

【docker手动创建redis镜像】宿主机上登录验证:
docker exec -it redis01 redis-cli(base) [root@centos redis_01]# docker exec -it redis01 redis-cli 127.0.0.1:6379> set name zhangsan OK 127.0.0.1:6379> get name "zhangsan" 127.0.0.1:6379>

远程登录docker的redis验证一下:
redis-cli -h 192.168.10.121 -p 16379(base) admin@apple > redis-cli -h 192.168.10.121 -p 16379 192.168.10.121:16379> set name wangwu OK 192.168.10.121:16379> get name "wangwu" 192.168.10.121:16379>

    推荐阅读