Dockerfile builds Redis image (yum method)

Table of contents

Dockerfile builds Redis image

1. Create a working directory

2. Write Dockerfile

3. Build a mirror image

4. Test container


Dockerfile builds Redis image

1. Create a working directory

[root@huyang1 ~]# mkdir redis

[root@huyang1 ~]# cd redis/

2. Write Dockerfile

[root@huyang1 redis]# vim Dockerfile

The configuration is as follows:

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. Build a mirror image

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

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

4. Test container

[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

 

Guess you like

Origin blog.csdn.net/2302_77582029/article/details/132087735