麒麟ARM64制作nginx,java,php,node基础镜像

一.环境准备

1.网上搜底层镜像

麒麟容器基础镜像:

 docker search kylin

镜像准备

docker pull kylin

注:最好自己制作底层镜像

2.自己做底层镜像

注:做镜像时需要在麒麟ARM操作系统上

1)准备麒麟镜像

# 1.创建工作目录,可以随意定,不能用/root
mkdir /home/kylin-docker-fs && cd /home/kylin-docker-fs

# 2.创建基础目录,dev 必须要创建,不然会提示找不到/dev/null
mkdir usr dev
cp -a /usr/lib /usr/lib64 /usr/bin /usr/share usr/

# 3.创建链接2
ln -s usr/lib lib
ln -s usr/lib64 lib64
ln -s usr/bin bin

# 4.复制配置以及root目录
cp -a /etc /root ./

# 5.裁剪部分脚本,不然会提示/proc 没有mount 
rm -rf etc/profile.d/flatpak.sh etc/profile.d/gawk.csh etc/profile.d/gawk.sh etc/profile.d/lang.csh etc/profile.d/lang.sh etc/profile.d/system-info.sh

# 6.测试镜像目录(切换根目录防止数据冗余,ctrl + d退出)
chroot .

# 7.镜像目录测试没有问题,打包
cd ..
tar -C kylin-docker-fs/ -z -c . -f kylin-armv8-docker.tar.gz

2)制作镜像

# 将制作的kylin.tar导入docker,镜像命名为kylin:v01
cat kylin-armv8-docker.tar.gz | docker import - kylin:v01

3.查看镜像与运行查看

# 查看镜像
~]# docker images | grep kylin
kylin      v01      fa3cb98dae64      6 hours ago     3.59GB
# 运行查看(注:需要host模式,否则yum会使用不了)
~]# docker run -it --net=host kylin:v01 /bin/bash
/ yum clean all
Unable to detect release version (use '--releasever' to specify release version)
0 files removed
/]# yum makecache
/]# yum -y install nfs-utils

二.制作nginx

~]# vim Dockerfile
FROM  kylin:v01
MAINTAINER kali_yao
ENV OPENRESTY_VERSION 1.19.9.1
ENV TZ=Asia/Shanghai
RUN yum -y install pcre-devel \
                zlib-devel \
                openssl-devel \
                gcc \
                unzip \
                make \
                vi \
                wget \
                make \ 
                perl \
                perl-devel \
    && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
    && mkdir /nginx \
    && cd /nginx \
    && wget https://openresty.org/download/openresty-$OPENRESTY_VERSION.tar.gz
RUN   cd /nginx \
      && tar -zxf openresty-1.19.9.1.tar.gz \
      && cd /nginx/openresty-1.19.9.1 \
      && ./configure  --prefix=/usr/local/tapd/openresty-$OPENRESTY_VERSION \
                      --with-threads \
                      --with-file-aio \
                      --with-pcre \
                      --with-pcre-jit \
                      --with-http_v2_module \
                      --with-http_realip_module \
                      --with-http_gunzip_module \
                      --with-http_gzip_static_module \
                      --with-http_secure_link_module \
                      --with-http_degradation_module \
                      --with-http_stub_status_module \
                      --without-http_memcached_module \
                      --without-mail_pop3_module \
                      --without-mail_imap_module \
                      --without-mail_smtp_module \
      && gmake -j2 \
      && make install

~]# docker build --no-cache -t nginx-server-arm64:1.0 . --network=host

三.制作java

~]# vim Dockerfile
FROM  kylin:v01
MAINTAINER kali_yao
ENV JAVA_VERSION 8u212
RUN mkdir /usr/java
ADD jdk-$JAVA_VERSION-linux-arm64-vfp-hflt.tar.gz /usr/java
RUN cd /usr/java \
    && mv /usr/java/jdk1.8.0_212 /usr/java/jdk
RUN rm -rf /usr/java
ENV JAVA_HOME /usr/java/jdk
ENV PATH ${PATH}:${JAVA_HOME}/bin

软件包需要到官网上下载,每下载一次隔一段时间需要登录官网账户 软件包:jdk-8u212-linux-arm64-vfp-hflt.tar.gz 链接:https://download.oracle.com/otn/java/jdk/8u212-b10/59066701cf1a433da9770636fbc4c9aa/jdk-8u212-linux-arm64-vfp-hflt.tar.gz

~]# docker build --no-cache -t nginx-server-arm64:1.3 . --network=host

四.制作php

~]# vim Dockerfile
FROM  kylin:v01
MAINTAINER kali_yao
ENV PHP_VERSION 7.2.34
ENV TZ=Asia/Shanghai
RUN yum -y install  \
           pcre-devel \
           zlib-devel \
           openssl-devel \
           gcc \
           unzip \
           make \
           vi \
           wget \
           make \ 
           perl \
           perl-devel \
           zlib \ 
           libxml \
           libjpeg \
           freetype \
           libpng \
           gd \
           curl \ 
           libiconv \
           libxml2 \
           libxml2-devel \
           libjpeg-devel \
           freetype-devel \
           libpng-devel \
           gd-devel \
           curl-devel \
           libxslt-devel \
           openssl \
           gmp-devel \
           coreutils 
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN \ 
     mkdir -p /data/www/conf/php7 \
     && mkdir -p /usr/local/tapd/php \
     && cd /data/www/conf/php7 \
     && wget https://museum.php.net/php7/php-$PHP_VERSION.tar.gz \
     && tar -xf php-$PHP_VERSION.tar.gz 
# install php
RUN PHP_CONFIG="\
        --prefix=/usr/local/tapd/php-$PHP_VERSION \
        --with-config-file-path=/usr/local/tapd/php-$PHP_VERSION/etc \
        --enable-fpm \
        --with-mhash \
        --enable-sockets \
        --enable-shared \
        --with-mysqli \
        --with-pdo-mysql \
        --with-pic \
        --enable-calendar \
        --enable-ctype \
        --enable-wddx \
        --with-gd \
        --enable-bcmath \
        --enable-ftp \
        --with-iconv \
        --enable-mbstring \
        --enable-sysvsem \
        --enable-sysvshm \
        --enable-soap \
        --with-libxml-dir=/usr/local/tapd/libxml2-2.9.2 \
        --with-jpeg-dir=/usr/local/tapd/libjpeg-9a \
        --with-png-dir=/usr/local/tapd/libpng-1.6.16 \
        --with-openssl \
        --with-curl=/usr/local/tapd/curl-7.41.0 \
        --with-freetype-dir=/usr/local/tapd/freetype-2.5.5 \
        --with-gmp=/usr/local/tapd/gmp-6.1.0 \
        --with-xsl=/usr/local/tapd/libxslt-1.1.28 \
        --enable-zip \
        --with-zlib \
    " 
RUN cd /data/www/conf/php7/php-$PHP_VERSION \
    && ./configure $PHP_CONFIG \ 
    && make \
    && make install \ 
    && ln -s /usr/local/tapd/php-$PHP_VERSION/ /usr/local/tapd/php \
    && ln -s /usr/local/tapd/php/bin/php /usr/bin/php \
    && rm -rf /data/www/conf/php7

~]# docker build --no-cache -t nginx-server-arm64:1.1 . --network=host

五.制作node

~]# vim Dockerfile
FROM  kylin:v01
MAINTAINER kali_yao
RUN yum -y install wget 
RUN cd /usr/local/  \
    && wget https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-arm64.tar.gz \
    && tar -xf node-v10.15.3-linux-arm64.tar.gz 
RUN mv /usr/local/node-v10.15.3-linux-arm64 /usr/local/node
RUN \
    ln -s /usr/local/node/bin/node /usr/local/bin/node \
    && ln -s /usr/local/node/bin/npm /usr/local/bin/npm

~}# docker build --no-cache -t nginx-server-arm64:1.4 . --network=host

六.汇总制作

~]# vim Dockerfile
FROM  kylin:v01
MAINTAINER kali_yao
ENV OPENRESTY_VERSION 1.19.9.1
ENV PHP_VERSION 7.2.34
ENV JAVA_VERSION 8u212
ENV TZ=Asia/Shanghai
RUN yum -y install  \
           pcre-devel \
           zlib-devel \
           openssl-devel \
           gcc \
           unzip \
           make \
           vi \
           wget \
           make \ 
           perl \
           perl-devel \
           zlib \ 
           libxml \
           libjpeg \
           freetype \
           libpng \
           gd \
           curl \ 
           libiconv \
           libxml2 \
           libxml2-devel \
           libjpeg-devel \
           freetype-devel \
           libpng-devel \
           gd-devel \
           curl-devel \
           libxslt-devel \
           openssl \
           gmp-devel \
           coreutils 
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN \ 
    mkdir /nginx \
    && cd /nginx \
    && wget https://openresty.org/download/openresty-$OPENRESTY_VERSION.tar.gz
RUN \ 
     mkdir -p /data/www/conf/php7 \
     && cd /data/www/conf/php7 \
     && wget https://museum.php.net/php7/php-$PHP_VERSION.tar.gz \
     && tar -xf php-$PHP_VERSION.tar.gz 
# install nginx
RUN NGINX_CONFIG="\
    --prefix=/usr/local/tapd/openresty-$OPENRESTY_VERSION \
    --with-threads \
    --with-file-aio \
    --with-pcre \
    --with-pcre-jit \
    --with-http_v2_module \
    --with-http_realip_module \
    --with-http_gunzip_module \
    --with-http_gzip_static_module \
    --with-http_secure_link_module \
    --with-http_degradation_module \
    --with-http_stub_status_module \
    --without-http_memcached_module \
    --without-mail_pop3_module \
    --without-mail_imap_module \
    --without-mail_smtp_module \
    " \
    && cd /nginx \
    && tar -zxf openresty-1.19.9.1.tar.gz \
    && cd /nginx/openresty-1.19.9.1 \
    && ./configure $NGINX_CONFIG \
    && gmake -j2 \
    && make install \
    && rm -rf /nginx
# install php
RUN PHP_CONFIG="\
        --prefix=/usr/local/tapd/php-$PHP_VERSION \
        --with-config-file-path=/usr/local/tapd/php-$PHP_VERSION/etc \
        --enable-fpm \
        --with-mhash \
        --enable-sockets \
        --enable-shared \
        --with-mysqli \
        --with-pdo-mysql \
        --with-pic \
        --enable-calendar \
        --enable-ctype \
        --enable-wddx \
        --with-gd \
        --enable-bcmath \
        --enable-ftp \
        --with-iconv \
        --enable-mbstring \
        --enable-sysvsem \
        --enable-sysvshm \
        --enable-soap \
        --with-libxml-dir=/usr/local/tapd/libxml2-2.9.2 \
        --with-jpeg-dir=/usr/local/tapd/libjpeg-9a \
        --with-png-dir=/usr/local/tapd/libpng-1.6.16 \
        --with-openssl \
        --with-curl=/usr/local/tapd/curl-7.41.0 \
        --with-freetype-dir=/usr/local/tapd/freetype-2.5.5 \
        --with-gmp=/usr/local/tapd/gmp-6.1.0 \
        --with-xsl=/usr/local/tapd/libxslt-1.1.28 \
        --enable-zip \
        --with-zlib \
    " 
RUN cd /data/www/conf/php7/php-$PHP_VERSION \
    && ./configure $PHP_CONFIG \ 
    && make \
    && make install \ 
    && ln -s  /usr/local/tapd/php-$PHP_VERSION/ /usr/local/tapd/php \
    && ln -s /usr/local/tapd/php/bin/php /usr/bin/php \
    && rm -rf /data/www/conf/php7
# install node
RUN cd /usr/local/  \
    && wget https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-arm64.tar.gz \
    && tar -xf node-v10.15.3-linux-arm64.tar.gz 
RUN mv /usr/local/node-v10.15.3-linux-arm64 /usr/local/node
RUN \
    ln -s /usr/local/node/bin/node /usr/local/bin/node \
    && ln -s /usr/local/node/bin/npm /usr/local/bin/npm
# install java
RUN mkdir /usr/java
ADD jdk-$JAVA_VERSION-linux-arm64-vfp-hflt.tar.gz /usr/java
RUN cd /usr/java \
    && mv /usr/java/jdk1.8.0_212 /usr/java/jdk
RUN rm -rf /usr/java
ENV JAVA_HOME /usr/java/jdk
ENV PATH ${PATH}:${JAVA_HOME}/bin

~]# docker build --no-cache -t nginx-server-arm64:1.0.0 . --network=host

你可能感兴趣的:(容器,麒麟linux,kubernetes,容器)