立即注册  找回密码
 立即注册
CeraNetworksBGVM服务器主机交流会员请立即修改密码Sharktech防护
查看: 131|回复: 0

alpine(JAVA环境)Docker基础镜像制作

[复制链接]

alpine(JAVA环境)Docker基础镜像制作

[复制链接]

81

主题

8

回帖

711

积分

高级会员

积分
711
土小帽

81

主题

8

回帖

711

积分

高级会员

积分
711
2023-11-3 21:30:07 | 显示全部楼层 |阅读模式
拉取官方alpine[ol]
  • docker pull alpine:latest[/ol]复制代码
    说明
    1). 考虑到国人习惯设置上海时区

    2). 依赖glibc,参考:https://github.com/sgerrand/alpine-pkg-glibc/

    3). 建议在大陆以外服务器制作镜像

    Dockerfile[ol]
  • # AlpineLinux with a glibc-2.29-r0 and Oracle Java 8
  • FROM alpine:latest
  • MAINTAINER Anastas Dancha
  • # thanks to Vladimir Krivosheev  aka @develar for smaller image
  • # and Victor Palma  aka @devx for pointing it out
  • # Java Version and other ENV
  • ENV JAVA_VERSION_MAJOR=8 \
  •     JAVA_VERSION_MINOR=202 \
  •     JAVA_VERSION_BUILD=08 \
  •     JAVA_PACKAGE=jdk \
  •     JAVA_JCE=standard \
  •     JAVA_HOME=/opt/jdk \
  •     PATH=${PATH}:/opt/jdk/bin \
  •     GLIBC_REPO=https://github.com/sgerrand/alpine-pkg-glibc \
  •     GLIBC_VERSION=2.29-r0 \
  •     LANG=C.UTF-8
  • # do all in one step
  • RUN set -ex && \
  •     [[ ${JAVA_VERSION_MAJOR} != 7 ]] || ( echo >&2 'Oracle no longer publishes JAVA7 packages' && exit 1 ) && \
  •     apk -U upgrade && \
  •     apk add tzdata libstdc++ curl ca-certificates bash && \
  •     cp -r -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
  •     wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
  •     for pkg in glibc-${GLIBC_VERSION} glibc-bin-${GLIBC_VERSION} glibc-i18n-${GLIBC_VERSION}; do curl -sSL ${GLIBC_REPO}/releases/download/${GLIBC_VERSION}/${pkg}.apk -o /tmp/${pkg}.apk; done && \
  •     apk add /tmp/*.apk && \
  •     rm -v /tmp/*.apk && \
  •     ( /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 && \
  •     /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib && \
  •     mkdir /opt && \
  •     curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie" -o /tmp/java.tar.gz \
  •       http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-b${JAVA_VERSION_BUILD}/1961070e4c9b4e26a04e7f5a083f551e/${JAVA_PACKAGE}-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.tar.gz && \
  •     JAVA_PACKAGE_SHA256=$(curl -sSL https://www.oracle.com/webfolder/s/digest/${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}checksum.html | grep -E "${JAVA_PACKAGE}-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64\.tar\.gz" | grep -Eo '(sha256: )[^ /tmp/java.tar.gz.sha256 && \
  •     sha256sum -c /tmp/java.tar.gz.sha256 && \
  •     gunzip /tmp/java.tar.gz && \
  •     tar -C /opt -xf /tmp/java.tar && \
  •     ln -s /opt/jdk1.${JAVA_VERSION_MAJOR}.0_${JAVA_VERSION_MINOR} /opt/jdk && \
  •     if [ "${JAVA_JCE}" == "unlimited" ]; then echo "Installing Unlimited JCE policy" >&2 && \
  •       curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie" -o /tmp/jce_policy-${JAVA_VERSION_MAJOR}.zip \
  •         http://download.oracle.com/otn-pub/java/jce/${JAVA_VERSION_MAJOR}/jce_policy-${JAVA_VERSION_MAJOR}.zip && \
  •       cd /tmp && unzip /tmp/jce_policy-${JAVA_VERSION_MAJOR}.zip && \
  •       cp -v /tmp/UnlimitedJCEPolicyJDK8/*.jar /opt/jdk/jre/lib/security; \
  •     fi && \
  •     sed -i s/#networkaddress.cache.ttl=-1/networkaddress.cache.ttl=10/ $JAVA_HOME/jre/lib/security/java.security && \
  •     apk del curl glibc-i18n && \
  •     rm -rf /opt/jdk/*src.zip \
  •            /opt/jdk/lib/missioncontrol \
  •            /opt/jdk/lib/visualvm \
  •            /opt/jdk/lib/*javafx* \
  •            /opt/jdk/jre/plugin \
  •            /opt/jdk/jre/bin/javaws \
  •            /opt/jdk/jre/bin/jjs \
  •            /opt/jdk/jre/bin/orbd \
  •            /opt/jdk/jre/bin/pack200 \
  •            /opt/jdk/jre/bin/policytool \
  •            /opt/jdk/jre/bin/rmid \
  •            /opt/jdk/jre/bin/rmiregistry \
  •            /opt/jdk/jre/bin/servertool \
  •            /opt/jdk/jre/bin/tnameserv \
  •            /opt/jdk/jre/bin/unpack200 \
  •            /opt/jdk/jre/lib/javaws.jar \
  •            /opt/jdk/jre/lib/deploy* \
  •            /opt/jdk/jre/lib/desktop \
  •            /opt/jdk/jre/lib/*javafx* \
  •            /opt/jdk/jre/lib/*jfx* \
  •            /opt/jdk/jre/lib/amd64/libdecora_sse.so \
  •            /opt/jdk/jre/lib/amd64/libprism_*.so \
  •            /opt/jdk/jre/lib/amd64/libfxplugins.so \
  •            /opt/jdk/jre/lib/amd64/libglass.so \
  •            /opt/jdk/jre/lib/amd64/libgstreamer-lite.so \
  •            /opt/jdk/jre/lib/amd64/libjavafx*.so \
  •            /opt/jdk/jre/lib/amd64/libjfx*.so \
  •            /opt/jdk/jre/lib/ext/jfxrt.jar \
  •            /opt/jdk/jre/lib/ext/nashorn.jar \
  •            /opt/jdk/jre/lib/oblique-fonts \
  •            /opt/jdk/jre/lib/plugin.jar \
  •            /tmp/* /var/cache/apk/* && \
  •     echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf
  • # EOF[/ol]复制代码
    参考:https://github.com/anapsix/docker-alpine-java

    生成镜像[ol]
  • docker build -t hub.linuxeye.com/library/alpine-java:latest .   #进入行dockerfile目录[/ol]复制代码
    推送镜像至私有仓库[ol]
  • docker push hub.linuxeye.com/library/alpine-java:latest[/ol]复制代码
  • 回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    Archiver|小黑屋|HS2V主机综合交流论坛

    GMT+8, 2024-12-27 03:45 , Processed in 0.014345 second(s), 3 queries , Gzip On, Redis On.

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

    快速回复 返回顶部 返回列表