redis

扫码查看

日常学习。。慢慢更新。。

dockerfile文件如下

from centos:7
RUN yum install vim net-tools tcl make gcc -y
ADD redis-5.0.7.tar.gz /opt/
RUN cd /opt/redis-5.0.7  \
    && make       \
    && make test  \
    && make install
RUN cp /opt/redis-5.0.7/redis.conf  /etc/redis.conf  \
    &&  sed -i 's/bind 127.0.0.1/#bind 127.0.0.1/g' /etc/redis.conf \
    &&  sed -i 's/daemonize no/daemonize yes/g'  /etc/redis.conf \
    &&  sed -i '$a\requirepass redis'  /etc/redis.conf
RUN echo -e "#!/bin/bash\nredis-server /etc/redis.conf \nsh " >> /root/run.sh
RUN chmod a+x /root/run.sh
CMD ["/root/run.sh"]

创建镜像

[root@dou redis]# docker build -t redis:v1 .
Sending build context to Docker daemon 202.4 MB
Step 1/8 : FROM centos:7
 ---> 08d05d1d5859
Step 2/8 : RUN yum install vim net-tools tcl make gcc -y
 ---> Using cache
 ---> ad582facf64d
Step 3/8 : ADD redis-5.0.7.tar.gz /opt/
 ---> Using cache
 ---> af8c2ddf726f
Step 4/8 : RUN cd /opt/redis-5.0.7      && make           && make test      && make install
 ---> Using cache
 ---> 48b3bfd1d32a
Step 5/8 : RUN cp /opt/redis-5.0.7/redis.conf  /etc/redis.conf      &&  sed -i 's/bind 127.0.0.1/#bind 127.0.0.1/g' /etc/redis.conf     &&  sed -i 's/daemonize no/daemonize yes/g'  /etc/redis.conf     &&  sed -i '$a\requirepass redis'  /etc/redis.conf
 ---> Using cache
 ---> 8338a3cc7d2b
Step 6/8 : RUN echo -e "#!/bin/bash\nredis-server /etc/redis.conf \nsh " >> /root/run.sh
 ---> Using cache
 ---> ecc27472d84f
Step 7/8 : RUN chmod a+x /root/run.sh
 ---> Using cache
 ---> f177325dec1b
Step 8/8 : CMD /root/run.sh
 ---> Using cache
 ---> d5ac3fc2210a
Successfully built d5ac3fc2210a
[root@dou redis]#

运行容器

docker run -itd --network doufy --ip 172.19.0.30 --name redis01 -h redis01 redis:v1

连接测试

[root@redis01 /]# redis-cli -h 172.19.0.30 -p 6379 -a redis
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
172.19.0.30:6379> ping
PONG
172.19.0.30:6379>

更新中。。。。

 

12-14 22:57
查看更多