增加redis
This commit is contained in:
parent
796694cf40
commit
a6cc527085
34
redis/4.0.10/Dockerfile
Normal file
34
redis/4.0.10/Dockerfile
Normal file
@ -0,0 +1,34 @@
|
||||
FROM centos:7
|
||||
|
||||
MAINTAINER Yang <yangyufans@qq.com>
|
||||
|
||||
ENV REDIS_VERSION=4.0.10
|
||||
|
||||
RUN yum install -y wget gcc make
|
||||
|
||||
RUN cd / && wget http://download.redis.io/releases/redis-$REDIS_VERSION.tar.gz \
|
||||
&& tar -zxvf redis-$REDIS_VERSION.tar.gz \
|
||||
&& rm -rf redis-$REDIS_VERSION.tar.gz \
|
||||
&& cd /redis-$REDIS_VERSION \
|
||||
&& make MALLOC=libc \
|
||||
&& make install \
|
||||
&& cp /redis-$REDIS_VERSION/redis.conf /usr/local/bin/ \
|
||||
&& cd / \
|
||||
&& rm -rf redis-$REDIS_VERSION
|
||||
|
||||
RUN mkdir /redis /redis/conf /redis/logs
|
||||
|
||||
RUN sed -i 's/logfile ""/logfile "\/redis\/logs\/redis.log"/' /usr/local/bin/redis.conf && \
|
||||
sed -i 's/bind 127.0.0.1/#bind 127.0.0.1/' /usr/local/bin/redis.conf
|
||||
|
||||
RUN echo "ZONE=Asia/Shanghai" > /etc/sysconfig/clock && \
|
||||
rm -rf /etc/localtime && \
|
||||
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
|
||||
COPY start.sh /
|
||||
|
||||
RUN chmod 777 /start.sh
|
||||
|
||||
EXPOSE 6379
|
||||
|
||||
ENTRYPOINT ["/start.sh"]
|
||||
11
redis/4.0.10/start.sh
Normal file
11
redis/4.0.10/start.sh
Normal file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! -e /redis/conf/redis.conf ]; then
|
||||
cp /usr/local/bin/redis.conf /redis/conf
|
||||
fi
|
||||
|
||||
if [ -n "$PASSWORD" ]; then
|
||||
echo "requirepass $PASSWORD" >> /redis/conf/redis.conf
|
||||
fi
|
||||
|
||||
redis-server /redis/conf/redis.conf
|
||||
16
redis/README.md
Normal file
16
redis/README.md
Normal file
@ -0,0 +1,16 @@
|
||||
# redis 搭建
|
||||
## 创建镜像
|
||||
```bash
|
||||
docker build -t redis:4.0.10 .
|
||||
```
|
||||
## 创建容器
|
||||
```bash
|
||||
docker run -d \
|
||||
--privileged=true \
|
||||
-p 6379:6379 \
|
||||
-v /data/redis/conf:/redis/conf \
|
||||
-v /data/redis/logs:/redis/logs \
|
||||
-e PASSWORD=123456 \
|
||||
--name redis-4.0.10 \
|
||||
redis:4.0.10
|
||||
```
|
||||
Loading…
Reference in New Issue
Block a user