麒麟ARM64制作nginx,java,php,node基础镜像
短信预约 -IT技能 免费直播动态提醒
一.环境准备
1.网上搜底层镜像
麒麟容器基础镜像:
docker search kylin
镜像准备
docker pull kylin
注:最好自己制作底层镜像
2.自己做底层镜像
注:做镜像时需要在麒麟ARM操作系统上
1)准备麒麟镜像
# 1.创建工作目录,可以随意定,不能用/rootmkdir /home/kylin-docker-fs && cd /home/kylin-docker-fs# 2.创建基础目录,dev 必须要创建,不然会提示找不到/dev/nullmkdir usr devcp -a /usr/lib /usr/lib64 /usr/bin /usr/share usr/# 3.创建链接2ln -s usr/lib libln -s usr/lib64 lib64ln -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:v01cat kylin-armv8-docker.tar.gz | docker import - kylin:v01
3.查看镜像与运行查看
# 查看镜像~]# docker images | grep kylinkylin v01 fa3cb98dae64 6 hours ago 3.59GB# 运行查看(注:需要host模式,否则yum会使用不了)~]# docker run -it --net=host kylin:v01 /bin/bash/ yum clean allUnable to detect release version (use '--releasever' to specify release version)0 files removed/]# yum makecache/]# yum -y install nfs-utils
二.制作nginx
~]# vim DockerfileFROM kylin:v01MAINTAINER kali_yaoENV OPENRESTY_VERSION 1.19.9.1ENV TZ=Asia/ShanghaiRUN 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.gzRUN 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 DockerfileFROM kylin:v01MAINTAINER kali_yaoENV JAVA_VERSION 8u212RUN mkdir /usr/javaADD jdk-$JAVA_VERSION-linux-arm64-vfp-hflt.tar.gz /usr/javaRUN cd /usr/java \ && mv /usr/java/jdk1.8.0_212 /usr/java/jdkRUN rm -rf /usr/javaENV JAVA_HOME /usr/java/jdkENV 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 DockerfileFROM kylin:v01MAINTAINER kali_yaoENV PHP_VERSION 7.2.34ENV TZ=Asia/ShanghaiRUN 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/timezoneRUN \ 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 phpRUN 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 DockerfileFROM kylin:v01MAINTAINER kali_yaoRUN 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/nodeRUN \ 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 DockerfileFROM kylin:v01MAINTAINER kali_yaoENV OPENRESTY_VERSION 1.19.9.1ENV PHP_VERSION 7.2.34ENV JAVA_VERSION 8u212ENV TZ=Asia/ShanghaiRUN 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/timezoneRUN \ mkdir /nginx \ && cd /nginx \ && wget https://openresty.org/download/openresty-$OPENRESTY_VERSION.tar.gzRUN \ 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 nginxRUN 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 phpRUN 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 nodeRUN 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/nodeRUN \ ln -s /usr/local/node/bin/node /usr/local/bin/node \ && ln -s /usr/local/node/bin/npm /usr/local/bin/npm# install javaRUN mkdir /usr/javaADD jdk-$JAVA_VERSION-linux-arm64-vfp-hflt.tar.gz /usr/javaRUN cd /usr/java \ && mv /usr/java/jdk1.8.0_212 /usr/java/jdkRUN rm -rf /usr/javaENV JAVA_HOME /usr/java/jdkENV PATH ${PATH}:${JAVA_HOME}/bin~]# docker build --no-cache -t nginx-server-arm64:1.0.0 . --network=host
来源地址:https://blog.csdn.net/kali_yao/article/details/128789591
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341