构建redis-4.0.11-Dockerfile

编写Dockerfile

FROM alpine:latest
MAINTAINER [email protected]
RUN apk add --no-cache --virtual .build-deps curl gcc supervisor linux-headers make musl-dev tar \
    && mkdir /data \
    && cd /data \
    && curl -sO http://download.redis.io/releases/redis-4.0.11.tar.gz  \
    && tar xf redis-4.0.11.tar.gz \ 
    && rm -fr redis-4.0.11.tar.gz \ 
    && rm -fr /var/cache/apk/* \ 
    && cd redis-4.0.11 \
    && make PREFIX=/usr/local/redis install \  
    && rm -fr redis-4.0.11 
COPY ./supervisord.conf /etc/supervisord.conf
COPY ./startredis.sh /startredis.sh
EXPOSE 6379/tcp
RUN chmod +x /startredis.sh
ONBUILD RUN /usr/bin/supervisorctl reload
EnTRYPOINT ["/startredis.sh"]
    ###nTR 是这个博客的违禁词语 我就小写了
#CMD ["/usr/local/redis/bin/redis-server","/etc/redis/redis.conf"]

redis.conf

     bind 0.0.0.0
     protected-mode yes
     port 6379
     tcp-backlog 511
     timeout 0
     tcp-keepalive 300
     daemonize  no
     supervised no
     pidfile /var/run/redis/redis.pid
     loglevel notice
     logfile /data/redis/redis.log
     databases 16
     always-show-logo yes
     save 900 1
     save 300 10
     save 60 10000
     stop-writes-on-bgsave-error yes
     rdbcompression yes
     rdbchecksum yes
     dbfilename dump.rdb
     dir /data/redis/
     slave-serve-stale-data yes
     slave-read-only yes
     repl-diskless-sync no
     repl-diskless-sync-delay 5
     repl-disable-tcp-nodelay no
     slave-priority 100
     maxmemory 495000000
     lazyfree-lazy-eviction no
     lazyfree-lazy-expire no
     lazyfree-lazy-server-del no
     slave-lazy-flush no
     appendonly no
     appendfilename "appendonly.aof"
     appendfsync everysec
     no-appendfsync-on-rewrite no
     auto-aof-rewrite-percentage 100
     auto-aof-rewrite-min-size 64mb
     aof-load-truncated yes
     aof-use-rdb-preamble no
     lua-time-limit 5000
     slowlog-log-slower-than 10000
     slowlog-max-len 128
     latency-monitor-threshold 0
     notify-keyspace-events ""
     hash-max-ziplist-entries 512
     hash-max-ziplist-value 64
     list-max-ziplist-size -2
     list-compress-depth 0
     set-max-intset-entries 512
     zset-max-ziplist-entries 128
     zset-max-ziplist-value 64
     hll-sparse-max-bytes 3000
     activerehashing yes
     client-output-buffer-limit normal 0 0 0
     client-output-buffer-limit slave 256mb 64mb 60
     client-output-buffer-limit pubsub 32mb 8mb 60
     hz 10
     aof-rewrite-incremental-fsync yes

supervisord.conf

  [unix_http_server]
  file=/run/supervisord.sock   ; (the path to the socket file)
  [supervisord]
  logfile=/var/log/supervisord.log ; (main log file;default $CWD/supervisord.log)
  loglevel=info                ; (log level;default info; others: debug,warn,trace)
  [rpcinterface:supervisor]
  supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
  [supervisorctl]
  serverurl=unix:///run/supervisord.sock ; use a unix:// URL  for a unix socket
  [program:redis-4.0.11]
  command=/bin/sh -c "exec /usr/local/redis/bin/redis-server /etc/redis/redis.conf"
  autostart=true
  autorestart=true
  startretries=0
  stdout_events_enabled=true
  stderr_events_enabled=true

startredis.sh

#!/bin/sh
nohup  supervisord  -n -c /etc/supervisord.conf &

构建容器

docker build -t fangxin:redis4.0.11 .

构建redis-4.0.11-Dockerfile

启动容器

docker run -itd -p 6399:6379 -v /etc/redis.conf:/etc/redis/redis.conf:rw -v /mnt/redis:/data/redis:rw -v /data/soft/redis/startredis.sh:/startredis.sh:rw --name redis4_0_11 fangxin3-redis:4.0.11

构建redis-4.0.11-Dockerfile

猜你喜欢

转载自blog.51cto.com/9025736/2432692