本篇内容主要讲解“alpine_glibc构建sun jdk 8的docker镜像的方法”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“alpine_glibc构建sun jdk 8的docker镜像的方法”吧!
构建系统基础镜像
alpine glibc 的Dockerfile内容如下:
alpine:3.6
MAINTAINER tongqiang<tongqiangyin@gmail.com>
# Here we install GNU libc (aka glibc) and set C.UTF-8 locale as default.
ENV ALPINE_GLIBC_BASE_URL https://github.com/sgerrand/alpine-pkg-glibc/releases/download
ENV ALPINE_GLIBC_PACKAGE_VERSION 2.25-r0
ENV ALPINE_GLIBC_BASE_PACKAGE_FILENAME glibc-$ALPINE_GLIBC_PACKAGE_VERSION.apk
ENV ALPINE_GLIBC_BIN_PACKAGE_FILENAME glibc-bin-$ALPINE_GLIBC_PACKAGE_VERSION.apk
ENV ALPINE_GLIBC_I18N_PACKAGE_FILENAME glibc-i18n-$ALPINE_GLIBC_PACKAGE_VERSION.apk
RUN apk add --no-cache --virtual=.build-dependencies wget ca-certificates \
&& wget \
"https://raw.githubusercontent.com/andyshinn/alpine-pkg-glibc/master/sgerrand.rsa.pub" \
-O "/etc/apk/keys/sgerrand.rsa.pub" \
&& wget \
"$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" \
&& apk add --no-cache \
"$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" \
&& rm "/etc/apk/keys/sgerrand.rsa.pub" \
&& /usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 C.UTF-8 || true \
&& echo "export LANG=C.UTF-8" > /etc/profile.d/locale.sh \
&& apk del glibc-i18n \
&& rm "/root/.wget-hsts" \
&& apk del .build-dependencies \
&& rm \
"$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_I18N_PACKAGE_FILENAME"
ENV LANG=C.UTF-8
构建基础镜像
docker build -it myimage/alpine_glibc:3.6 .
在基础镜像上构建sun jdk 8镜像
alpine glibc jdk 8的Dockerfile内容如下:
FROM myimage/alpine_glibc:3.6
MAINTAINER "tongqiang<tongqiangyin@gmail.com>"
ENV JAVA_VERSION 8
ENV JAVA_UPDATE 151
ENV JAVA_BUILD 12
ENV JAVA_PATH e758a0de34e24606bca991d704f6dcbf
ENV JAVA_HOME /usr/local/jvm/default-jvm
ENV JAVA_DOWNLOAD_URL http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION}u${JAVA_UPDATE}-b${JAVA_BUILD}/${JAVA_PATH}/jdk-${JAVA_VERSION}u${JAVA_UPDATE}-linux-x64.tar.gz
ENV JCE_DOWNLOAD_URL http://download.oracle.com/otn-pub/java/jce/${JAVA_VERSION}/jce_policy-${JAVA_VERSION}.zip
RUN apk add --no-cache bash tar wget ca-certificates unzip \
&& mkdir -p ${JAVA_HOME} \
&& wget --header "Cookie: oraclelicense=accept-securebackup-cookie;" ${JAVA_DOWNLOAD_URL} \
&& tar -xzf jdk-${JAVA_VERSION}u${JAVA_UPDATE}-linux-x64.tar.gz -C ${JAVA_HOME} --strip-components=1 \
&& wget --header "Cookie: oraclelicense=accept-securebackup-cookie;" ${JCE_DOWNLOAD_URL} \
&& unzip -jo -d ${JAVA_HOME}/jre/lib/security jce_policy-${JAVA_VERSION}.zip \
&& ln -s ${JAVA_HOME}/bin/* /usr/bin/ \
&& apk del tar wget ca-certificates unzip \
&& rm -rf jdk-${JAVA_VERSION}u${JAVA_UPDATE}-linux-x64.tar.gz \
${JAVA_HOME}/*src.zip \
${JAVA_HOME}/jre/lib/security/README.txt \
jce_policy-${JAVA_VERSION}.zip \
/tmp/*
构建sun jdk 8镜像
docker build -it myimage/alpine_glibc_jdk:8 .
到此,相信大家对“alpine_glibc构建sun jdk 8的docker镜像的方法”有了更深的了解,不妨来实际操作一番吧!这里是天达云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!