#本地已有镜像 FROM docker.io/centos #作者信息 MAINTAINER liangyj "liangyj@566560.com" #安装依赖工具 RUN yum install -y gcc gcc-c++ make autoconf ncurses-devel #下载cmkae ADD /usr/local/src #编译安装cmake WORKDIR /usr/local/src RUN tar xzvf cmake-3.0.2.tar.gz WORKDIR /usr/local/src/cmake-3.0.2 RUN ./bootstrap RUN make RUN make install #添加本地mysql至容器中 ADD ./mysql-5.6.21.tar.gz /usr/local/src #创建mysql用户及目录 RUN mkdir -p /usr/local/mysql/data RUN groupadd mysql RUN useradd -g mysql -s /sbin/nologin mysql RUN chown -R mysql:mysql /usr/local/mysql #编译安装mysql WORKDIR /usr/local/src/mysql-5.6.21 RUN ["cmake","-DCMAKE_INSTALl_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci"] RUN ["make"] RUN ["make","install"] #初始化数据库 RUN /usr/local/mysql/scripts/mysql_install_db --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql --user=mysql #添加启动脚本 RUN cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld RUN chmod +x /etc/init.d/mysqld #暴露端口 EXPOSE 3306 #修改PATH RUN sed -i ‘$ a export PATH=/usr/local/mysql/bin:$PATH‘ /etc/profile RUN source /etc/profile WORKDIR / #删除cmake mysql源码包及解压包 RUN rm -rf /usr/local/src/cmake-3.0.2.tar.gz RUN rm -rf /usr/local/src/cmake-3.0.2 RUN rm -rf /usr/local/src/mysql-5.6.21
本文出自 “ubuntu” 博客,请务必保留此出处http://thankinglove.blog.51cto.com/2311485/1794986
原文地址:http://thankinglove.blog.51cto.com/2311485/1794986