码迷,mamicode.com
首页 > 其他好文 > 详细

构建redis-4.0.11-Dockerfile

时间:2019-08-26 18:00:13      阅读:85      评论:0      收藏:0      [点我收藏+]

标签:vol   soft   nbu   its   cpu   logo   red   cmd   test   

编写Dockerfile
FROM alpine:latest
MAINTAINER hz7726@163.com
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 .

技术图片

启动容器

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

技术图片

docker-compose

root@mysql-2:/data/soft/redis# cat docker-compose.yaml
version: "3"
services:
  redis:
    image: fangxin:redis4.0.11
    restart: always
    container_name: test-redis4.0.11
    hostname: redis4.0.11
    sysctls:
      net.core.somaxconn: ‘1024‘
      #fs.file-max: ‘100000‘
    volumes:
      - "/etc/localtime:/etc/localtime:ro"
      - "/etc/redis.conf:/etc/redis/redis.conf:rw"
      - "/mnt/redis:/data/redis:rw"
      - "/data/soft/redis/startredis.sh:/startredis.sh:rw"
      - "/data/soft/redis/supervisord.conf:/etc/supervisord.conf:rw"
    dns:
      - "8.8.8.8"
    ports:
      - "6400:6379"
    ulimits:
      nproc: 65535
      nofile:
        soft: 20000
        hard: 40000
    deploy:
      resources:
        limits:
          cpus: "0.30"
          memory: "512M"
    healthcheck:
      test: ["CMD","nc -v -w 5 localhost -z 6379||exit 1"]
      interval: 60s
      timeout: 10s
      retries: 3

docker-compose up -d
技术图片

构建redis-4.0.11-Dockerfile

标签:vol   soft   nbu   its   cpu   logo   red   cmd   test   

原文地址:https://blog.51cto.com/9025736/2432692

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!