The following is installed with the official RPM source package MySQL too slow does not advocate the use of Yum this way
The "tutum" of the #本文参考了 Dockerfile
From Docker.io/centos:latest
Maintainer Waitfish
#设置环境变量, all operations are non-interactive
ENV Debian_frontend noninteractive
RUN echo "Asia/shanghai" >/etc/timezone
#注意这里要更改系统的时区设置, because the time zone is often used in Web applications, the default CentOS will make your application this program incredibly effective.
#安装mysql服务
RUN Yum update-y && \
Yum install wget rpm-y && \
#wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm && \ #下载速度太慢
wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm && \
#rpm-ivh mysql-community-release-el7-5.noarch.rpm--nosignature && \
Yum Localinstall mysql57-community-release-el7-7.noarch.rpm-y && \
RPM--import/etc/pki/rpm-gpg/rpm-gpg-key-centos-7 && \
Yum Install Mysql-community-server-y
# Remove pre-installed database files
RUN rm-rf/var/lib/mysql/*
# Add a MYSQL configuration file under a folder
ADD my.cnf/etc/mysql/conf.d/my.cnf
ADD mysqld_charset.cnf/etc/mysql/conf.d/mysqld_charset.cnf
# Add a MYSQL script
ADD import_sql.sh/import_sql.sh
ADD run.sh/run.sh
RUN chmod 755/*.sh
# Set environment variables, user names and secrets
ENV Mysql_user Admin
ENV Mysql_pass **random**
# Setting environment variables in master-slave copy mode
ENV Replication_master **false**
ENV Replication_slave **false**
ENV replication_user Replica
ENV replication_pass Replica
# Set the volume that can be mounted, which can be used to back up the database and configuration files
VOLUME ["/etc/mysql", "/var/lib/mysql"]
# set ports that can be mapped
EXPOSE 3306
# set a self-starting script
CMD ["/run.sh"]
*************************************************************************************************************** *************************************************************************************************************** ***************************************************
Using Dockerfile to create a CentOS docker image with MySQL