DockerFile部署lnmp+memcached+redis+mongodb开发环境for Redis(五)

1、下载基础镜像centos
1
docker pull centos:6
2、查看一下大小
1
2
3
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos 6 70b5d81549ec 2 months ago 195MB
3、创建文件夹存放Redis的Dockerfile,以及源码包等等,为后期docker-compose做准备
1
mkdir -p /data/docker/lnmp-test/dockerfile/redis
4、创建Redis的Dockerfile
1
vim /data/docker/lnmp-test/dockerfile/redis/Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
FROM centos:6

LABEL maintainer="1012405802@qq.com" description="Redis image"

COPY redis-3.0.2.tar.gz /root/redis-3.0.2.tar.gz

RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 \
&& yum -y install gcc \
&& tar -zxvf /root/redis-3.0.2.tar.gz -C /root/ \
&& cd /root/redis-3.0.2 \
&& make PREFIX=/usr/local/redis install \
&& ln -s /usr/local/redis/bin/* /usr/local/bin/ \
&& mkdir -p /etc/redis \
&& mkdir -p /data/redis \
&& mkdir -p /data/log \
&& cp /root/redis-3.0.2/redis.conf /etc/redis/ \
&& sed -i 's#logfile ""#logfile /data/log/redis.log#' /etc/redis/redis.conf \
&& sed -i 's#dir ./#dir /data/redis#' /etc/redis/redis.conf \
&& sed -i 's#appendonly no#appendonly yes#' /etc/redis/redis.conf \
&& rm -rf /root/redis* \
&& yum clean all

EXPOSE 6379

CMD ["redis-server","/etc/redis/redis.conf"]
5、把redis源码包上传到/data/docker/lnmp-test/dockerfile/redis/目录下
6、创建镜像
1
2
cd /data/docker/lnmp-test/dockerfile/redis/
docker build -t centos6:redis .
7、查看镜像大小
1
2
3
4
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos6 redis f06d5e0b0a71 4 seconds ago 395MB
centos 6 70b5d81549ec 3 months ago 195MB
8、启动容器测试是否成功
1
docker run -d -p 6379:6379 --name redis centos6:redis

iS2oKf.png

9、宿主机开启防火墙6379端口
1
2
firewall-cmd --add-port=6379/tcp --permanent
systemctl restart firewalld
博主QQ:1012405802
技术交流QQ群:830339411
版权声明:网站内容有原创和转载,如有侵权,请联系删除,谢谢!!
感谢打赏,93bok因你们而精彩!!(支付宝支持花呗)
0%