Dockerfile building Mirror

1, Dockerfile parameters

FROM build a new image is based on which a mirror 
LABEL label 
run when RUN building Mirror Shell command 
COPY to copy files or directories to mirror 
ENV set the environment variable 
USER is RUN, CMD and ENTRYPOINT execute commands to specify run user 
EXPOSE statement container operation service port 
WORKDIR working directory rUN, CMD, ENTRYPOINT, COPY and ADD is set to 
perform a ENTRYPOINT run container, if there are multiple ENTRYPOINT instructions, the last one will 
perform when running CMD container, if there are multiple CMD command, the last one will

1.1 build Nginx mirror

[root @ K8S-node1 ~] # mkdir nginx 
[root @ K8S -node1 ~] # cd nginx / 
[root @ K8S -node1 nginx] # CAT Dockerfile 
# Name: containerized Nginx 
# Uses: Web services 
# Created: 2018.06 . . 11 
the FROM CentOS 
the LABEL Q the MAINTAINER on 
the RUN yum  the install EPEL-Release - Y 
the RUN yum  the install - Y Nginx 
EXPOSE 80 
the WORKDIR / usr / local 
the CMD [ " Nginx " , " -g " , " daemon OFF;"]

 -t -f specifies the name of the specified Dockerfile. In dockerfile context, the representative of the current directory

[root@k8s-node1 nginx]# docker build -t  nginx:v1 -f Dockerfile .  

View Mirror

[root@k8s-node1 nginx]# docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
nginx                   v1                  4ab138f8031a        2 minutes ago       346MB

Start container

[root@k8s-node1 nginx]# docker run -d -p 8887:80 nginx:v1
dc2e3f33171f49fb8ae9b9ddd21b1a0d1d46d33b37d31350b19e6cadef9e6be1

View

[root@k8s-node1 nginx]# docker ps -l
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
dc2e3f33171f        nginx:v1            "nginx -g 'daemon of…"   19 seconds ago      Up 18 seconds       0.0.0.0:8887->80/tcp   sad_hopper

access

2. Construction of PHP mirroring

[root@k8s-node1 dockerfile]# cd php/
[root@k8s-node1 php]# ls
Dockerfile  php-5.6.36.tar.gz  php-fpm.conf  php.ini
[root@k8s-node1 php]# cat Dockerfile 
FROM centos:7
MAINTAINER www.ctnrs.com
RUN yum install epel-release -y && \
    yum install -y gcc gcc-c++ make gd-devel libxml2-devel \
    libcurl-devel libjpeg-devel libpng-devel openssl-devel \
    libmcrypt-devel libxslt-devel libtidy-devel autoconf \
    iproute net-tools telnet wget curl && \
    yum clean all && \
    rm -rf /var/cache/yum/*

COPY php-5.6.36.tar.gz /
RUN tar zxf php-5.6.36.tar.gz && \
    cd php-5.6.36 && \
    ./configure --prefix=/usr/local/php \
    --with-config-file-path=/usr/local/php/etc \
    --enable-fpm --enable-opcache \
    --with-mysql --with-mysqli --with-pdo-mysql \
    --with-openssl --with-zlib --with-curl --with-gd \
    --with-jpeg-dir --with-png-dir --with-freetype-dir \
    --enable-mbstring --with-mcrypt --enable-hash && \
    make -j 4 && make install && \
    cp php.ini-production /usr/local/php/etc/php.ini && \
    cp sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf && \
    sed -i "90a \daemonize = no" /usr/local/php/etc/php-fpm.conf && \
    mkdir /usr/local/php/log && \
    cd / && rm -rf php* && \
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

ENV PATH $PATH:/usr/local/php/sbin
COPY php.ini /usr/local/php/etc/
COPY php-fpm.conf /usr/local/php/etc/
WORKDIR /usr/local/php
EXPOSE 9000
CMD ["php-fpm"]

 

Guess you like

Origin www.cnblogs.com/w787815/p/11992999.html