Dockerfile 创建redis容器

Dockerfile内容

FROM ansible/centos7-ansible:latest

MAINTAINER JPinsz
RUN yum clean all
RUN yum makecache fast
RUN rpm --rebuilddb;yum install make wget vim gzip passwd openssh-server gcc -y
RUN rm -rf /etc/yum.repos.d/*;wget -P /etc/yum.repos.d/ http://mirrors.163.com/.help/CentOS7-Base-163.repo
#配置SSHD&修改root密码为123

RUN ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N ''
RUN ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''
RUN ssh-keygen -q -t ed25519 -f /etc/ssh/ssh_host_ED25519_key -N ''
RUN echo '123' | passwd --stdin root

RUN wget -P /tmp/ http://download.redis.io/releases/redis-5.0.2.tar.gz

RUN cd /tmp/;tar xzf redis-5.0.2.tar.gz;cd redis-5.0.2;make;make PREFIX=/usr/local/redis install;mkdir -p /usr/local/redis/etc/;cp redis.conf /usr/local/redis/etc/

RUN mkdir -p /data/redis/
RUN sed -i 's#^dir.*#dir /data/redis#g' /usr/local/redis/etc/redis.conf

VOLUME ["/data/redis"]

RUN sed -i '/^bind/s/127.0.0.1/0.0.0.0/g' /usr/local/redis/etc/redis.conf
RUN echo "export PATH=/usr/local/redis/bin:$PATH" >> /etc/profile
RUN source /etc/profile

EXPOSE  22
EXPOSE  6379
CMD /usr/sbin/sshd;/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf

 

posted @ 2020-08-25 13:32  JPinsz  阅读(290)  评论(0编辑  收藏  举报