2021年云计算技能大赛第二天gpmall容器化

2021年云计算技能大赛第二天gpmall容器化

1. mariadb容器化

Dockerfile

FROM centos:centos7.5.1804
MAINTAINER Chinaskill
RUN rm -rvf /etc/yum.repos.d/*
COPY gpmall-repo /opt/
COPY local.repo /etc/yum.repos.d/
COPY run.sh /opt/
COPY gpmall.sql /opt/
ENV LC_ALL en_US.UTF-8
RUN yum install -y mariadb-server && bash /opt/run.sh
EXPOSE 3306
CMD ["mysqld_safe"]
run.sh 初始化脚本
#!/bin/bash
mysql_install_db 
mysqld_safe &
sleep 8
mysqladmin -uroot password '123456'
mysql -uroot -p123456 -e "grant all on *.* to root@'%' identified by '123456';flush privileges;"
mysql -uroot -p123456 -e "create database gpmall;use gpmall;source /opt/gpmall.sql"
local.repo文件
[gpmall]
name=gpmall
baseurl=file:///opt/gpmall-repo
enabled=1
gpgcheck=0

2.Redis容器化

Dockerfile

FROM centos:centos7.5.1804
MAINTAINER Chinaskill
RUN rm -rvf /etc/yum.repos.d/*
COPY gpmall-repo /opt/
COPY local.repo /etc/yum.repos.d/
RUN yum install -y redis
RUN sed -i 's/bind 127.0.0.1/bind 0.0.0.0/g' /etc/redis.conf && 
    sed -i 's/protected-mode yes/protected-mode no/g' /etc/redis.conf
EXPOSE 6379
CMD ["redis-cli","/etc/redis.conf"]

3.Zookeeper容器化

FROM centos:centos7.5.1804
MAINTAINER Chinaskill
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
RUN yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
RUN mkdir /opt/zookeeper
ADD zookeeper-3.4.14.tar.gz /opt/zookeeper/
RUN echo "source /root/.bash_profile" > /opt/zookeeper/start.sh &&\
        echo "cp /opt/zookeeper/zookeeper-3.4.14/conf/zoo_sample.cfg /opt/zookeeper/zookeeper-3.4.14/conf/zoo.cfg" >> /opt/zookeeper/start.sh &&\
        echo "/opt/zookeeper/zookeeper-3.4.14/bin/zkServer.sh start-foreground" >> /opt/zookeeper/start.sh
EXPOSE 2181
ENTRYPOINT ["sh","/opt/zookeeper/start.sh"]

4.Kafka容器化

FROM centos:centos7.5.1804
MAINTAINER Chinaskill
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
RUN yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
RUN mkdir /opt/kafka
ADD kafka_2.11-1.1.1.tgz /opt/kafka
RUN sed -i -e "s/num.partitions.*$/num.partitions=3/g" /opt/kafka/kafka_2.11-1.1.1/config/server.properties
RUN echo "source /root/.bash_profile" > /opt/kafka/start.sh &&\
    echo "cd /opt/kafka/kafka_2.11-1.1.1">> /opt/kafka/start.sh &&\
    echo "sed -i 's%zookeeper.connect=.*$%zookeeper.connect=mall-zookeeper:2181%g'  /opt/kafka/kafka_2.11-1.1.1/config/server.properties" >> /opt/kafka/start.sh &&\
    echo "bin/kafka-server-start.sh config/server.properties" >> /opt/kafka/start.sh &&\
    chmod a+x /opt/kafka/start.sh
EXPOSE 9092
ENTRYPOINT ["sh","/opt/kafka/start.sh"]

更多2020、2021云计算技能大赛资料+Q 2492246121讨论

你可能感兴趣的:(笔记,云计算,容器,docker)