Docker 制作镜像-redis

1: 先创建dockerfile目录
mkdir -pv /docker/redis

2: redis安装脚本vim /docker/redis/install.sh
yum install -y net-tools gcc gcc-c++ make tar openssl openssl-devel cmake

cd /usr/local/src
wget 'http://download.redis.io/releases/redis-4.0.9.tar.gz'
tar -zxf redis-4.0.9.tar.gz
cd redis-4.0.9
make && make PREFIX=/usr/local/redis install

mkdir -pv /usr/local/redis/conf /usr/local/redis/bin
cp src/redis* /usr/local/redis/bin/

3: redis的配置文件vim /docker/redis/redis.conf
bind 127.0.0.1
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile "/tmp/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 /tmp/
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
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

4: 前台启动redis
/usr/local/redis/bin/redis-server /docker/redis/redis.conf

5: Dockerfile编写
FROM centos7
MAINTAINER liming [email protected]
COPY install.sh /tmp/install.sh
COPY CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo
RUN sh /tmp/install.sh; \rm -rf /usr/local/src/*
COPY redis.conf /usr/local/redis/conf/redis.conf

6: 构建镜像
docker build -t my_redis .

7: 测试能否正常启动redis server
docker run -d my_redis /bin/bash -c '/usr/local/redis/bin/redis-server /usr/local/redis/conf/redis.conf'

转载于:https://www.cnblogs.com/mountain2011/p/11306126.html

你可能感兴趣的:(Docker 制作镜像-redis)