DockerFile

DockerFile

Dockerfile格式

Dockerfile指令:

Build镜像

Usage: docker build [OPTIONS] PATH | URL | - [flags]
Options:
-t, --tag list # 镜像名称
-f, --file string # 指定Dockerfile文件位置
# docker build .
# docker build -t shykes/myapp .
# docker build -t shykes/myapp -f /path/Dockerfile /path
# docker build -t shykes/myapp http://www.example.com/Dockerfile

 构建NGINX:

 1 FROM centos:7
 2 MAINTAINER www.ctnrs.com
 3 RUN yum install -y gcc gcc-c++ make \
 4     openssl-devel pcre-devel gd-devel \
 5     iproute net-tools telnet wget curl && \
 6     yum clean all && \
 7     rm -rf /var/cache/yum/*
 8 RUN wget http://nginx.org/download/nginx-1.15.5.tar.gz && \
 9     tar zxf nginx-1.15.5.tar.gz && \
10     cd nginx-1.15.5 && \
11     ./configure --prefix=/usr/local/nginx \
12     --with-http_ssl_module \
13     --with-http_stub_status_module && \
14     make -j 4 && make install && \
15     rm -rf /usr/local/nginx/html/* && \
16     echo "ok" >> /usr/local/nginx/html/status.html && \
17     cd / && rm -rf nginx-1.12.2* && \
18     ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
19 
20 ENV PATH $PATH:/usr/local/nginx/sbin
21 COPY nginx.conf /usr/local/nginx/conf/nginx.conf
22 WORKDIR /usr/local/nginx
23 EXPOSE 80
24 CMD ["nginx", "-g", "daemon off;"]
View Code

构建Tomcat

 1 FROM centos:7
 2 MAINTAINER www.ctnrs.com
 3 
 4 ENV VERSION=8.0.46
 5 
 6 RUN yum install java-1.8.0-openjdk wget curl unzip iproute net-tools -y && \
 7     yum clean all && \
 8     rm -rf /var/cache/yum/*
 9 
10 #RUN wget http://mirrors.shu.edu.cn/apache/tomcat/tomcat-8/v${VERSION}/bin/apache-tomcat-${VERSION}.tar.gz && \
11 RUN wget http://192.168.31.211/apache-tomcat-${VERSION}.tar.gz && \
12     tar zxf apache-tomcat-${VERSION}.tar.gz && \
13     mv apache-tomcat-${VERSION} /usr/local/tomcat && \
14     rm -rf apache-tomcat-${VERSION}.tar.gz /usr/local/tomcat/webapps/* && \
15     mkdir /usr/local/tomcat/webapps/test && \
16     echo "ok" > /usr/local/tomcat/webapps/test/status.html && \
17     sed -i '1a JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom"' /usr/local/tomcat/bin/catalina.sh && \
18     ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
19 
20 ENV PATH $PATH:/usr/local/tomcat/bin
21 
22 WORKDIR /usr/local/tomcat
23 
24 EXPOSE 8080
25 CMD ["catalina.sh", "run"]
View Code

构建Php

 1 FROM centos:7
 2 MAINTAINER www.ctnrs.com
 3 RUN yum install epel-release -y && \
 4     yum install -y gcc gcc-c++ make gd-devel libxml2-devel \
 5     libcurl-devel libjpeg-devel libpng-devel openssl-devel \
 6     libmcrypt-devel libxslt-devel libtidy-devel autoconf \
 7     iproute net-tools telnet wget curl && \
 8     yum clean all && \
 9     rm -rf /var/cache/yum/*
10 
11 RUN wget http://docs.php.net/distributions/php-5.6.36.tar.gz && \
12     tar zxf php-5.6.36.tar.gz && \
13     cd php-5.6.36 && \
14     ./configure --prefix=/usr/local/php \
15     --with-config-file-path=/usr/local/php/etc \
16     --enable-fpm --enable-opcache \
17     --with-mysql --with-mysqli --with-pdo-mysql \
18     --with-openssl --with-zlib --with-curl --with-gd \
19     --with-jpeg-dir --with-png-dir --with-freetype-dir \
20     --enable-mbstring --with-mcrypt --enable-hash && \
21     make -j 4 && make install && \
22     cp php.ini-production /usr/local/php/etc/php.ini && \
23     cp sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf && \
24     sed -i "90a \daemonize = no" /usr/local/php/etc/php-fpm.conf && \
25     mkdir /usr/local/php/log && \
26     cd / && rm -rf php* && \
27     ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
28 
29 ENV PATH $PATH:/usr/local/php/sbin
30 COPY php.ini /usr/local/php/etc/
31 COPY php-fpm.conf /usr/local/php/etc/
32 WORKDIR /usr/local/php
33 EXPOSE 9000
34 CMD ["php-fpm"]
View Code

 

posted @ 2018-11-29 17:29  Jacob先生  阅读(319)  评论(0编辑  收藏  举报