构建mysql5.7镜像,同时包含JDK运行环境,具体示例如下:
FROM centos:7
WORKDIR /data
COPY ./data
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& mkdir -p /data/mysql/data/3307 \
&& mkdir -p /data/mysql/tmp \
&& mv /data/my.cnf /data/mysql \
&& cd /data \
&& yum install -y libaio git \
&& tar -zxvf jdk-8u151-linux-x64.tar.gz \
&& tar -zxvf mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz \
&& rm -rf /data/*.tar.gz \
&& mv /data/mysql-5.7.16-linux-glibc2.5-x86_64/data/mysql/base \
&& useradd mysql \
&& chown-R mysql:mysql/data/mysql \
&& echo"n" | ssh-keygen-t rsa-f ~/.ssh/id_rsa-P"" \
&& cat/data/git_key> ~/.ssh/id_rsa \
&& chmod0600 -R ~/.ssh/ \
&& chmod u+x/data/init_mysql.sh \
&& echo' StrictHostKeyChecking no' >> /etc/ssh/ssh_config \
&& echo' UserKnownHostsFile /dev/null' >> /etc/ssh/ssh_config \
&& echo"export JAVA_HOME=/data/jdk1.8.0_151" >> /etc/profile \
&& echo"export PATH=$JAVA_HOME/bin:$PATH" >> /etc/profile \
&& source/etc/profile \
&& yum clean all
# ENV JAVA_HOME /data/jdk1.8.0_151
CMD ["sh /data/init_mysql.sh"]
网友评论