以下是我在学习中所遇到的一些Dockerfile的编写,后续将会继续补充进来
1.构建chinaskill-redis:v1.1镜像
具体要求如下:
(1)基础镜像:centos:centos7.5.1804;(2)作者:cqcet;(3)修改配置文件中的bind 127.0.0.1为bind 0.0.0.0;(4)设置Redis免密,并关闭保护模式;(5)开放端口:6379;(6)设置服务开机自启。
Dockerfile编写
FROM centos:7.5.1804 MAINTAINER cqcet RUN rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm \ && yum install -y redis \ && sed -i "s/bind 127.0.0.1/bind 0.0.0.0/g" /etc/redis.conf \ && sed -i "s/protected-mode no/protected-mode yes/g" /etc/redis.conf EXPOSE 6379 ENTRYPOINT ["redis-server","/etc/redis.conf"] CMD ["redis-server"]
镜像构建
docker build --network=host -t chinaskill-redis:v1.1 .
2.构建chinaskill-kafka:v1.1镜像
具体要求如下:
(1)基础镜像:centos:centos7.5.1804;(2)作者:cqcet;(3)开放端口:9092;(4)设置服务开机自启。
dockerfile编写
FROM centos:7.5.1804 MAINTAINER cqcet RUN rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm RUN yum install -y java-11-* ADD zookeeper-3.4.14.tar.gz /opt/zookeeper RUN cp /opt/zookeeper/zookeeper-3.4.14/conf/zoo_sample.cfg /opt/zookeeper/zookeeper-3.4.14/conf/zoo.cfg \ && /opt/zookeeper/zookeeper-3.4.14/bin/zkServer.sh start EXPOSE 2181 ADD kafka_2.11-1.1.1.tgz /opt/kafka RUN /opt/kafka/kafka_2.11-1.1.1/bin/kafka-server-start.sh -daemon /opt/kafka/kafka_2.11-1.1.1/config/server.properties EXPOSE 9092 ENTRYPOINT ["sh","/opt/zookeeper/binzkServer.sh start","/opt/kafka/bin/kafka-server-start.sh -daemon /opt/kafka/config/server.properties"]
镜像构建
docker build --network=host -t chinaskill-kafka:v1.1 .
感谢大家,点赞,收藏,关注,评论!