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 イメージ 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 redis をインストールします

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

 

おすすめ

転載: blog.csdn.net/2302_77582029/article/details/132087735