本文共 1520 字,大约阅读时间需要 5 分钟。
#本地已有镜像FROM docker.io/centos#作者信息MAINTAINER liangyj "liangyj@566560.com"#安装依赖工具RUN yum install -y gcc gcc-c++ make autoconf ncurses-devel#下载cmkaeADD /usr/local/src#编译安装cmakeWORKDIR /usr/local/srcRUN tar xzvf cmake-3.0.2.tar.gzWORKDIR /usr/local/src/cmake-3.0.2RUN ./bootstrapRUN makeRUN make install#添加本地mysql至容器中ADD ./mysql-5.6.21.tar.gz /usr/local/src#创建mysql用户及目录RUN mkdir -p /usr/local/mysql/dataRUN groupadd mysqlRUN useradd -g mysql -s /sbin/nologin mysqlRUN chown -R mysql:mysql /usr/local/mysql#编译安装mysqlWORKDIR /usr/local/src/mysql-5.6.21RUN ["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/mysqldRUN chmod +x /etc/init.d/mysqld#暴露端口EXPOSE 3306#修改PATHRUN sed -i '$ a export PATH=/usr/local/mysql/bin:$PATH' /etc/profileRUN source /etc/profileWORKDIR /#删除cmake mysql源码包及解压包RUN rm -rf /usr/local/src/cmake-3.0.2.tar.gzRUN rm -rf /usr/local/src/cmake-3.0.2RUN rm -rf /usr/local/src/mysql-5.6.21
转载于:https://blog.51cto.com/thankinglove/1794986