一、Dockerfile文件:
#Version 1.0 at 2016-04-12 #Author:http://sunday208.blog.51cto.com/ #Base images FROM centos #MAINTAINER MAINTAINER http://sunday208.blog.51cto.com/ #ADD ADD tcl8.6.5-src.tar.gz /usr/local/src ADD redis-3.0.7.tar.gz /usr/local/src ADD CentOS-Base.repo /usr/local/src #RUN RUN \cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime RUN rm -rf /etc/yum.repos.d/*.repo RUN mv /usr/local/src/*.repo /etc/yum.repos.d/ RUN yum clean all RUN yum -y install wget net-tools gcc gcc-c++ make #WORKDIR WORKDIR /usr/local/src/tcl8.6.5/unix RUN ./configure --prefix=/usr --without-tzdata --mandir=/usr/share/man $([ $(uname -m) = x86_64 ] && echo --enable-64bit) RUN make && sed -e "s@^\(TCL_SRC_DIR=‘\).*@\1/usr/include‘@" -e "/TCL_B/s@=‘\(-L\)\?.*unix@=‘\1/usr/lib@" -i tclConfig.sh RUN make test && make install && make install-private-headers && ln -v -sf tclsh8.6 /usr/bin/tclsh && chmod -v 755 /usr/lib/libtcl8.*.so RUN echo -e "/lib \n /lib64 \n /usr/lib \n /usr/lib64 \n /usr/local/lib \n /usr/local/lib64 ">>/etc/ld.so.conf RUN ldconfig WORKDIR /usr/local/src/redis-3.0.7 RUN make RUN make install RUN cp src/redis-trib.rb /usr/local/bin/ && cp src/redis-server /usr/local/bin/redis-server && chmod +x /usr/local/bin/redis-server RUN mkdir /redisdata RUN rm -rf /usr/local/src/{redis-3*,tcl*} ADD redis.conf /etc/redis.conf WORKDIR /root RUN yum -y remove gcc gcc-c++ make RUN ln -sf /dev/stdout /tmp/redis.log VOLUME ["/redisdata"] ENV REDIS_VERSION 3.0.7 ENV REDIS_PORT 6379 ENV REDIS_DATA /redisdata EXPOSE 6379 CMD /usr/local/bin/redis-server /etc/redis.conf
二、下载所需软件:
[root@CentOS7-81 redis]# ls build.sh CentOS-Base.repo Dockerfile epel-7.repo redis-3.0.7.tar.gz redis.conf tcl8.6.5-src.tar.gz
三、执行使用镜像:
docker build -t redis:v1 /opt/docker/redis
四、运行容器:
五、测试:
[root@CentOS7-84 ~]# echo "set key1 http://sunday208.blog.51cto.com/addblog.php" | redis-cli -c -p 4034 -h 192.168.12.81 OK [root@CentOS7-84 ~]# echo "get key1" | redis-cli -c -p 4034 -h 192.168.12.81 "http://sunday208.blog.51cto.com/addblog.php" [root@CentOS7-84 ~]#
六、需要解决:
集群化配置。后面再测试。
本文出自 “都市布衣” 博客,请务必保留此出处http://sunday208.blog.51cto.com/377871/1762947
用dockerfile配置生成docker image并实现容器部署(redis服务)
原文地址:http://sunday208.blog.51cto.com/377871/1762947