(1)创建Dockerfile文件
[[email protected] ~]# vi Dockerfile
FROM centos:centos6
MAINTAINER cxm<[email protected]>
RUN yum update && yum clean all
RUN yum install -y wget
RUN wget http://download.redis.io/releases/redis-3.0.2.tar.gz
RUN tar zxvf redis-3.0.2.tar.gz
RUN cd redis-3.0.2
RUN yum groupinstall -y "Development Tools"
RUN cd redis-3.0.2 && make
RUN cp redis-3.0.2/redis.conf /etc/
RUN cp redis-3.0.2/src/redis-benchmark redis-3.0.2/src/redis-cli redis-3.0.2/src/redis-server /usr/bin/
RUN sed -i ‘s/daemonize no/daemonize yes/g‘ /etc/redis.conf
EXPOSE 6379
CMD ["redis-server", "/etc/redis.conf"]
(2)根据Dockerfile文件创建镜像
docker build -t cxm:redis --rm .
(3)启动容器
docker run -d --name redis -p 6380:6379 cxm:redis redis-server
或
docker run -d --name redis -p 6380:6379 cxm:redis /sbin/init