offical images CentOS7,add ssh server & nginx & java8,you can run nginx or java command.
147
The winter227/base-os image provides a Docker container running CentOS7 with ssh server、nginx and java8. This image is based on the official Centos image.
start a container as follows:
docker run -itd --name base-os --privileged=true -p 30022:22 -p 30080:80 winter227/base-os /usr/sbin/init
FROM centos:7.8.2003
ENV LANG=zh_CN.UTF-8 LANGUAGE=zh_CN:zh LC_ALL=zh_CN.UTF-8
#Install tools
RUN yum update -y
RUN yum reinstall -y glibc-common
RUN yum install -y telnet net-tools
RUN yum install -y wget
#安装gcc等工具,用来编译nginx
RUN yum install -y gcc make pcre-devel zlib-devel
#安装ssh服务,用于远程连接
RUN yum install -y openssl openssh-server
RUN yum clean all
#下载nginx,并编译
RUN cd /usr/local/src && wget http://nginx.org/download/nginx-1.8.1.tar.gz && tar zxfv nginx-1.8.1.tar.gz && cd nginx-1.8.1 && ls && ./configure --prefix=/usr/local/nginx --with-pcre && make && make install
RUN chmod +x /usr/local/nginx/sbin/nginx
RUN ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
RUN mkdir /temp
#ADD nginx /temp/
ADD nginx.service /temp/
RUN cd /temp/ && wget https://file.speedchinars.cn:6085/group1/xiangyang/jdk-8u231-linux-x641.tar.gz
RUN mv /temp/nginx.service /usr/lib/systemd/system/ && cd /usr/lib/systemd/system/ && chmod a+x nginx.service && systemctl enable nginx
#RUN mv /temp/nginx /etc/init.d/ && cd /etc/init.d/ && chmod a+x nginx && chkconfig --add nginx && chkconfig nginx on
RUN mkdir /speedchina/ && mkdir /speedchina/env/ && mv /temp/jdk-8u231-linux-x641.tar.gz /speedchina/env/ && cd /speedchina/env/ && tar zxfv jdk-8u231-linux-x641.tar.gz
#添加JDK8环境变量
RUN echo export JAVA_HOME=/speedchina/env/jdk1.8.0_231 >> /etc/profile
RUN echo export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/ >> /etc/profile
RUN echo export PATH=$PATH:$JAVA_HOME/bin >> /etc/profile
RUN source /etc/profile
#创建java指令相关软连接
RUN ln -s /speedchina/env/jdk1.8.0_231/bin/java /usr/bin/java
RUN ln -s /speedchina/env/jdk1.8.0_231/bin/javac /usr/bin/javac
RUN ln -s /speedchina/env/jdk1.8.0_231/bin/jar /usr/bin/jar
#自启ssh服务
RUN systemctl enable sshd
#修改默认root密码为root
RUN echo root:root|chpasswd
#RUN wget http://nginx.org/download/nginx-1.8.1.tar.gz
#RUN tar zxfv nginx-1.8.1.tar.gz
#RUN cd nginx-1.8.1 && ls && ./configure --prefix=/usr/local/nginx --with-pcre && make && make install
#RUN ls
#RUN ./configure --prefix=/usr/local/nginx --with-pcre
#RUN make && make install
RUN rm -rf /tmp/* rm -rf /var/cache/yum/*
RUN localedef -c -f UTF-8 -i zh_CN zh_CN.UTF-8
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#Define default command.
CMD ["bash"]
#启动脚本命令
#./usr/local/nginx/sbin/nginx
#停止脚本
#./usr/local/nginx/sbin/nginx stop
#重新加载配置文件
#./usr/local/nginx/sbin/nginx -s reload
#nginx指令软链接
#ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
#java指令软链接
#ln -s /speedchina/env/jdk1.8.0_231/bin/java /usr/bin/java
#ln -s /speedchina/env/jdk1.8.0_231/bin/javac /usr/bin/javac
#ln -s /speedchina/env/jdk1.8.0_231/bin/jar /usr/bin/jar
#启动ssh的服务:
#systemctl start sshd.service
#设置开机自动启动ssh服务
#systemctl enable sshd.service
#docker stop base-os
#docker rm base-os
#docker rmi os/base
#docker build -t os/base .
#docker run -itd --name base-os --privileged=true -p 30022:22 -p 30080:80 os/base /usr/sbin/init
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Content type
Image
Digest
Size
979.1 MB
Last updated
about 5 years ago
docker pull winter227/base-os:1.0