Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Make an image by Dockerfile

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Dockerfile Make Mirror Directory: Dockerfile scripts for tomcat Dockerfile scripts for nginx.1.12.0 Dockerfile scripts for mysql Dockerfile scripts for deleting errors Mirrors and containers scripts Dockerfile scripts for tomcat cd/optmkdir tomcatcd tomcatvim Dockerfiledir FROM CENTOS: 7 MAINTAINER this is tomcat ADD jdk-8u91-linux-x64.tar.gz/usr/local/WORKDIR/usr/local/RUN mv jdk1.8.0_91/usr/local/javascript aENV JAVA_HOME/usr/local/javaENV JAVA_BIN/usr/local/java/binENV JRE_HOME/usr/local/java/jreENV PATH $PATH:/usr/local/java/bin:/usr/local/java/jre/bin:/usr/local/java/lib:/usr/local/java/jre/lib/charsets.jarADD apache-tomcat-8.5.16.tar.gz/usr/localWORKDIR/usr/local/RUN mv apache-tomcat-8.5.16/usr/local/tomcat8EXPOSE 8080ENTRYPOINT ["/usr/local/tomcat8/bin/www.example.com "," run "] docker build-t tomcat: centos. docker run-d--name tomcat01-p 1216:8080-it tomcat: Dockerfile script cd/optmkdir nginxcd nginxvim Dockerfile FROM centos: 7MAINTAINER this is nginx RUN yum-y updateRUN yum-y install wget pcre-devel zlib-devel make zlib gcc gcc-c ++ openssl-devel net-toolslib RUN useradd-M-s/sbin/nologin nginxADD nginx-1.12.0.tar.gz/usr/local/srcWORKDIR/usr/local/srcWORKDIR nginx-1.12.0RUN./ configure\--prefix =/usr/local/nginx\--user = nginx\--group = nginx\--with-http_stub_status_module && make && make installENV PATH/usr/local/nginx/sbin:$PATHEXPOSE 80EXPOSE 443RUN echo "daemon off;">/usr/local/nginx/conf/nginx. confWORKDIR/root/nginxADD www.example.com/run. shRUN chmod 755/www.example.com CMD ["/run.sh "]#nginx startup file vim run.sh#!/ bin/bash/usr/local/nginx/sbin/nginxdocker build-t nginx: new. docker run-d-P nginx: newmysql Dockerfile script mkdir mysqlcd mysql/vim DockerfileFROM centos: 7MAINTAINER this is mysql RUN yum-y update #install mysql RUN yum-y install\ncurses\ncurses-devel\bison\cmake\gcc\gcc-c ++#create user RUN useradd-s/sbin/nbin ologin mysql #upload jingxADD mysql-boost-5.7.20.tar.gz/usr/local/src #compile install WORKDIR/usr/local/src/mysql-5.7.20/DCRUN cmake\-MAKE_INSTALL_PREFIX =/usr/local/mysql\-DMYSQL_UNIX_ADDR =/usr/local/mysql. sock\-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 && make && make install #Database directory make permission adjustment RUN chown-R mysql: mysql/usr/local/mysql/#Adjust configuration file RUN rm-rf/rf/my.cnfADD my.cnf/etc. RUN chown mysql: mysql/my.cnf #Set environment variable ENV PATH =/usr/local/mysql/bin:/usr/local/mysql/lib: etc $PATH #Initialize database WORKDIR/usr/local/mysql/RUN bin/mysqld\--initialize-insecure\--user = mysql\--basedir =/usr/local/mysql\--datadir =/usr/local/mysql/dataRUN cp/usr/local/mysql/usr/lib/systemd/system/mysqld. service/usr/lib/systemd/system/ADD www.example.com/run. shRUN chmod 755/www.example.com EXPOSE 3306CMD ["/run.sh "]#CMD [" mRUN ysql_safe "]#my. cnf Initiate script vim my. cnf [root@localhost mysql-5.7.20]#vi/etc/my. cnf [client] port = 3306default-character-set = utf8socket =/usr/local/mmf ysql/mysql. sock [mysql] port = 3306default-character-set = utf8socket =/usr/local/mysql/mysql. sock [mysqld] run.sh to 'root'@'%' identified by 'abc123';" && \mysql -e "grant all privileges on *.* to 'root '@' %' localhost identified by 'abc123';"docker build-t centos: mysql. docker run--name = mysql_server-d-P--privileged centos: mysql/usr/bin/initialize-insecure docker exec-it mirror ID/bin/bash delete error mirror and container cd/optvim none.sh#!/ bin/bashdocker ps -a | grep "Exited" | awk '{print $1 }' |xargs docker stopdocker ps -a | grep "Exited" | awk '{print $1 }' |xargs docker rmdocker images | grep none | awk '{print $3 }' | xargs docker rmi

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report