真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

如何編寫Dockerfile腳本

這篇文章的知識(shí)點(diǎn)包括:編寫tomcat的Dockerfile腳本、編寫nginx.1.12.0的Dockerfile腳本、編寫MySQL的Dockerfile腳本以及刪除錯(cuò)誤鏡像和容器腳本,閱讀完整文相信大家對(duì)Dockerfile腳本的編寫有了一定的認(rèn)識(shí)。tomcat的Dockerfile腳本

鄄城ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書合作)期待與您的合作!

cd /opt
mkdir tomcat
cd tomcat
vim Dockerfile
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/java
ENV JAVA_HOME /usr/local/java
ENV JAVA_BIN /usr/local/java/bin
ENV JRE_HOME /usr/local/java/jre
ENV PATH $PATH:/usr/local/java/bin:/usr/local/java/jre/bin
ENV CLASSPATH /usr/local/java/jre/bin:/usr/local/java/lib:/usr/local/java/jre/lib/charsets.jar
ADD apache-tomcat-8.5.16.tar.gz /usr/local
WORKDIR /usr/local/
RUN mv apache-tomcat-8.5.16 /usr/local/tomcat8
EXPOSE 8080

ENTRYPOINT ["/usr/local/tomcat8/bin/catalina.sh","run"]
docker build -t tomcat:centos .
docker run -d --name tomcat01 -p 1216:8080 -it tomcat:centos

nginx.1.12.0的Dockerfile腳本

cd /opt
mkdir nginx
cd nginx
vim Dockerfile 
FROM centos:7
MAINTAINER this is nginx 
RUN yum -y update
RUN yum -y install wget pcre-devel zlib-devel make zlib gcc gcc-c++ openssl-devel net-tools
RUN useradd -M -s /sbin/nologin nginx
ADD nginx-1.12.0.tar.gz /usr/local/src
WORKDIR /usr/local/src
WORKDIR nginx-1.12.0
RUN ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module && make && make install
ENV PATH /usr/local/nginx/sbin:$PATH
EXPOSE 80
EXPOSE 443
RUN echo "daemon off;">>/usr/local/nginx/conf/nginx.conf
WORKDIR /root/nginx
ADD run.sh /run.sh
RUN chmod 755 /run.sh
CMD ["/run.sh"]

#nginx啟動(dòng)文檔
vim run.sh
#!/bin/bash
/usr/local/nginx/sbin/nginx

docker build -t nginx:new .
docker run -d -P nginx:new

mysql的Dockerfile腳本

mkdir mysql
cd mysql/
vim Dockerfile
FROM centos:7
MAINTAINER this is mysql 
RUN yum -y update
#安裝mysql依懶環(huán)境包
RUN yum -y install \
ncurses \
ncurses-devel \
bison \
cmake \
make \
gcc \
gcc-c++ 
#創(chuàng)建運(yùn)行用戶
RUN useradd -s /sbin/nologin mysql
#上傳jingx
ADD mysql-boost-5.7.20.tar.gz /usr/local/src
#編譯安裝
WORKDIR /usr/local/src/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 && make && make install
#數(shù)據(jù)庫目錄進(jìn)行權(quán)限調(diào)整
RUN chown -R mysql:mysql /usr/local/mysql/
#調(diào)整配置文件
RUN rm -rf /etc/my.cnf
ADD my.cnf /etc
RUN chown mysql:mysql /etc/my.cnf
#設(shè)置環(huán)境變量
ENV PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
#初始化數(shù)據(jù)庫
WORKDIR /usr/local/mysql/
RUN bin/mysqld \
--initialize-insecure \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
RUN cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
ADD run.sh /run.sh
RUN chmod 755 /run.sh
EXPOSE 3306
CMD ["/run.sh"]

#CMD ["mysql_safe"]

#my.cnf啟動(dòng)腳本
vim my.cnf
[root@localhost mysql-5.7.20]#vi /etc/my.cnf
[client]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock

[mysql]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock

[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
character_set_server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES

#mysql權(quán)限腳本
vim run.sh
/usr/bin/systemctl start mysql.server && \
mysql -e "grant all privileges on *.* 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  鏡像ID  /bin/bash

刪除錯(cuò)誤鏡像和容器

cd /opt

vim none.sh

#!/bin/bash docker ps -a | grep "Exited" | awk '{print $1 }' |xargs docker stop docker ps -a | grep "Exited" | awk '{print $1 }' |xargs docker rm docker images | grep none | awk '{print $3 }' | xargs docker rmi

關(guān)于Dockerfile腳本的編寫就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。


當(dāng)前題目:如何編寫Dockerfile腳本
本文來源:http://weahome.cn/article/gehjcp.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部