构建redis-4.0.11-Dockerfile
2019-08-26 16:53
1206 查看
编写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 15da 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
相关文章推荐
- dockerfile 构建 redis 镜像
- Docker利用 Dockerfile构建 redis3.2.9
- dockerfile构建redis镜像及如何跳过确认交互
- docker使用dockerfile 构建redis镜像
- Docker 安装 Redis 方法一、通过 Dockerfile 构建 创建Dockerfile 首先,创建目录redis,用于存放后面的相关东西。 runoob@runoob:~$ mkdir -
- 使用Docker构建redis集群--最靠谱的版本
- 使用Docker构建redis集群
- 如何使用Dockerfile构建Docker镜像
- 使用dockerfile构建nginx镜像
- 使用Dockerfile构建镜像(Nginx,Tomcat,MySQL)
- 使用Docker构建redis集群--最靠谱的版本
- docker笔记之构建nginx的Dockerfile
- Dockerfile与Docker构建流程解读
- Docker使用Dockerfile构建简单镜像
- Dockerfile 中的 multi-stage(多阶段构建)
- 使用dockerfile构建镜像
- Docker如何使用Dockerfile构建镜像
- Docker技术剖析--dockerfile构建容器
- 利用dockerfile构建mysql容器
- 运维-makefile的书写(节省dockerFile的批量构建的问题)