Dockerfile构建Redis镜像(yum方式)

目录

Dockerfile构建Redis镜像

1、建立工作目录

2、编写Dockerfile文件

3、构建镜像

4、测试容器


Dockerfile构建Redis镜像

1、建立工作目录

[root@huyang1 ~]# mkdir redis

[root@huyang1 ~]# cd redis/

2、编写Dockerfile文件

[root@huyang1 redis]# vim Dockerfile

配置如下:

FROM centos:7
MAINTAINER Crushlinux <[email protected]>

RUN yum -y update && yum -y install epel-release && yum -y install redis
RUN sed -i -e 's@bind 127.0.0.1@bind 0.0.0.0@g' /etc/redis.conf
RUN sed -i -e 's@protected-mode yes@protected-mode no@g' /etc/redis.conf
RUN echo "requirepass 123456" >> /etc/redis.conf

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
EXPOSE 6379

CMD [ "/usr/bin/redis-server","/etc/redis.conf"]

3、构建镜像

[root@localhost redis]# docker build -t redis:new .

[root@localhost redis]# docker images redis:new

4、测试容器

[root@localhost redis]# docker run -d -p 6379:6379 --name redis-test  redis:new

[root@localhost redis]# rpm -ivh /root/epel-release-latest-7.noarch.rpm

[root@localhost redis]# yum -y install redis

[root@localhost redis]# redis-cli -h localhost -a 123456

猜你喜欢

转载自blog.csdn.net/2302_77582029/article/details/132087735