FROM centos:7
MAINTAINER "xxxxx@qq.com"
#project
RUN mkdir /projectfile
# RUN 执行以下命令
#JDK 8
RUN mkdir /usr/local/java
ADD jdk-8u171-linux-x64.tar.gz /usr/local/java/
RUN ln -s /usr/local/java/jdk1.8.0_171 /usr/local/java/jdk
ENV JAVA_HOME /usr/local/java/jdk
ENV JRE_HOME ${JAVA_HOME}/jre
ENV CLASSPATH .:${JAVA_HOME}/lib:${JRE_HOME}/lib
ENV PATH ${JAVA_HOME}/bin:$PATH
#yum
RUN yum clean all
RUN yum -y update && yum -y install epel-release && yum -y install redis
RUN yum install -y pcre-devel wget net-tools zlib zlib-devel make openssl-devel
RUN yum -y install ncurses ncurses-devel bison cmake gcc gcc-c++
#添加用户
RUN useradd -s /sbin/nologin mysql
ADD mysql-boost-5.7.20.tar.gz /usr/local
WORKDIR /usr/local/mysql-5.7.20
RUN cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DSYSCONFDIR=/etc \
-DSYSTEMD_PID_DIR=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_BOOST=boost \
-DWITH_SYSTEMD=1
RUN make -j4 && make install
RUN chown -R mysql:mysql /usr/local/mysql
#删除原有的配置文件
RUN rm -rf /etc/my.cnf
#添加新的配置文件
ADD my.cnf /etc/my.cnf
#设置环境变量
ENV PATH /usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
WORKDIR /usr/local/mysql/
#初始化数据库
RUN bin/mysqld \
--initialize-insecure \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
RUN cp usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
EXPOSE 3306
#配置启动脚本
RUN echo -e "#!/bin/bash \nsystemctl enable mysqld" > /run.sh
RUN chmod +x /run.sh
RUN sh /run.sh
#CMD ["init"]
#nginx-1.8.0
#ADD http://nginx.org/download/nginx-1.8.0.tar.gz .
#RUN tar zxvf nginx-1.8.0.tar.gz
RUN mkdir nginx-1.8.0
ADD nginx-1.8.0.tar.gz .
RUN mkdir -p /usr/local/nginx
RUN cd nginx-1.8.0 && ./configure --prefix=/usr/local/nginx && make && make install
RUN rm -fv /usr/local/nginx/conf/nginx.conf
COPY nginx_conf /usr/local/nginx/conf/nginx.conf
EXPOSE 80
#CMD /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#CMD ["/usr/local/nginx/sbin/nginx","-c","/usr/local/nginx/conf/nginx.conf"]
#redis
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
EXPOSE 6379
RUN sed -i -e 's@bind 127.0.0.1@bind 0.0.0.0@g' /etc/redis.conf
RUN sed -i -e 's@protected-mode yes@protected-mode no@g' /etc/redis.conf
RUN echo "requirepass 711s9d31" >> /etc/redis.conf
#CMD [ "/usr/bin/redis-server","/etc/redis.conf"]
CMD init && /usr/bin/redis-server /etc/redis.conf && /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#shell 命令
[root@192 centosNew]# docker run -d -p 80:80 -p 443:443 -p 6379:6379 -p 3306:3306 --name centos41 --restart always --privileged=true centos:new5
37db401208285a5f0f0adff584d47a5541c5be4b36cb8a69f62ad7bc1b348014
[root@192 centosNew]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
37db40120828 centos:new5 "/bin/sh -c 'init ..." 5 seconds ago Restarting (1) Less than a second ago centos41
[root@192 centosNew]# docker logs centos41
Couldn't find an alternative telinit implementation to spawn.
Couldn't find an alternative telinit implementation to spawn.
Couldn't find an alternative telinit implementation to spawn.
Couldn't find an alternative telinit implementation to spawn.
Couldn't find an alternative telinit implementation to spawn.
Couldn't find an alternative telinit implementation to spawn.