Using Dockerfile to create a CentOS docker image with MySQL

Source: Internet
Author: User
Tags gpg

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.