构建redis-4.0.11-Dockerfile

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了构建redis-4.0.11-Dockerfile相关的知识,希望对你有一定的参考价值。

编写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的主要内容,如果未能解决你的问题,请参考以下文章

47-Jenkins-终止构建并设置构建结果

47-Jenkins-终止构建并设置构建结果

Groovy构建工具 ( 构建工具引入 | Gradle 构建工具作用 | 传统的依赖管理 )

每次构建项目时如何避免构建和构建通用框架?

使用自动工具构建系统/在单独的“构建”目录中构建

jenkins 构建触发器 以及参数的传递