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

k8s评论2阅读模式

拉取官方alpine

  1. docker pull alpine:latest

说明

1). 考虑到国人习惯设置上海时区

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

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

Dockerfile

  1. # AlpineLinux with a glibc-2.29-r0 and Oracle Java 8
  2. FROM alpine:latest
  3. MAINTAINER Anastas Dancha <anapsix@random.io>
  4. # thanks to Vladimir Krivosheev <develar@gmail.com> aka @develar for smaller image
  5. # and Victor Palma <palma.victor@gmail.com> aka @devx for pointing it out
  6. # Java Version and other ENV
  7. ENV JAVA_VERSION_MAJOR=8 \
  8.     JAVA_VERSION_MINOR=202 \
  9.     JAVA_VERSION_BUILD=08 \
  10.     JAVA_PACKAGE=jdk \
  11.     JAVA_JCE=standard \
  12.     JAVA_HOME=/opt/jdk \
  13.     PATH=${PATH}:/opt/jdk/bin \
  14.     GLIBC_REPO=https://github.com/sgerrand/alpine-pkg-glibc \
  15.     GLIBC_VERSION=2.29-r0 \
  16.     LANG=C.UTF-8
  17. # do all in one step
  18. RUN set -ex && \
  19.     [[ ${JAVA_VERSION_MAJOR} != 7 ]] || ( echo >&2 'Oracle no longer publishes JAVA7 packages' && exit 1 ) && \
  20.     apk -U upgrade && \
  21.     apk add tzdata libstdc++ curl ca-certificates bash && \
  22.     cp -r -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
  23.     wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
  24.     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 && \
  25.     apk add /tmp/*.apk && \
  26.     rm -v /tmp/*.apk && \
  27.     ( /usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 C.UTF-8 || true ) && \
  28.     echo "export LANG=C.UTF-8" > /etc/profile.d/locale.sh && \
  29.     /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib && \
  30.     mkdir /opt && \
  31.     curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie" -o /tmp/java.tar.gz \
  32.       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 && \
  33.     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: )[^<]+' | cut -d: -f2 | xargs) && \
  34.     echo "${JAVA_PACKAGE_SHA256}  /tmp/java.tar.gz" > /tmp/java.tar.gz.sha256 && \
  35.     sha256sum -c /tmp/java.tar.gz.sha256 && \
  36.     gunzip /tmp/java.tar.gz && \
  37.     tar -C /opt -xf /tmp/java.tar && \
  38.     ln -s /opt/jdk1.${JAVA_VERSION_MAJOR}.0_${JAVA_VERSION_MINOR} /opt/jdk && \
  39.     if [ "${JAVA_JCE}" == "unlimited" ]; then echo "Installing Unlimited JCE policy" >&2 && \
  40.       curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie" -o /tmp/jce_policy-${JAVA_VERSION_MAJOR}.zip \
  41.         http://download.oracle.com/otn-pub/java/jce/${JAVA_VERSION_MAJOR}/jce_policy-${JAVA_VERSION_MAJOR}.zip && \
  42.       cd /tmp && unzip /tmp/jce_policy-${JAVA_VERSION_MAJOR}.zip && \
  43.       cp -v /tmp/UnlimitedJCEPolicyJDK8/*.jar /opt/jdk/jre/lib/security; \
  44.     fi && \
  45.     sed -i s/#networkaddress.cache.ttl=-1/networkaddress.cache.ttl=10/ $JAVA_HOME/jre/lib/security/java.security && \
  46.     apk del curl glibc-i18n && \
  47.     rm -rf /opt/jdk/*src.zip \
  48.            /opt/jdk/lib/missioncontrol \
  49.            /opt/jdk/lib/visualvm \
  50.            /opt/jdk/lib/*javafx* \
  51.            /opt/jdk/jre/plugin \
  52.            /opt/jdk/jre/bin/javaws \
  53.            /opt/jdk/jre/bin/jjs \
  54.            /opt/jdk/jre/bin/orbd \
  55.            /opt/jdk/jre/bin/pack200 \
  56.            /opt/jdk/jre/bin/policytool \
  57.            /opt/jdk/jre/bin/rmid \
  58.            /opt/jdk/jre/bin/rmiregistry \
  59.            /opt/jdk/jre/bin/servertool \
  60.            /opt/jdk/jre/bin/tnameserv \
  61.            /opt/jdk/jre/bin/unpack200 \
  62.            /opt/jdk/jre/lib/javaws.jar \
  63.            /opt/jdk/jre/lib/deploy* \
  64.            /opt/jdk/jre/lib/desktop \
  65.            /opt/jdk/jre/lib/*javafx* \
  66.            /opt/jdk/jre/lib/*jfx* \
  67.            /opt/jdk/jre/lib/amd64/libdecora_sse.so \
  68.            /opt/jdk/jre/lib/amd64/libprism_*.so \
  69.            /opt/jdk/jre/lib/amd64/libfxplugins.so \
  70.            /opt/jdk/jre/lib/amd64/libglass.so \
  71.            /opt/jdk/jre/lib/amd64/libgstreamer-lite.so \
  72.            /opt/jdk/jre/lib/amd64/libjavafx*.so \
  73.            /opt/jdk/jre/lib/amd64/libjfx*.so \
  74.            /opt/jdk/jre/lib/ext/jfxrt.jar \
  75.            /opt/jdk/jre/lib/ext/nashorn.jar \
  76.            /opt/jdk/jre/lib/oblique-fonts \
  77.            /opt/jdk/jre/lib/plugin.jar \
  78.            /tmp/* /var/cache/apk/* && \
  79.     echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf
  80. # EOF

参考:https://github.com/anapsix/docker-alpine-java

生成镜像

  1. docker build -t hub.linuxeye.com/library/alpine-java:latest .   #进入行dockerfile目录

推送镜像至私有仓库

  1. docker push hub.linuxeye.com/library/alpine-java:latest

Mon Feb 18 11:12:38 CST 2019

 
  • 本文由 yeho 发表于 2019-02-18
  • 转载请务必保留本文链接:https://linuxeye.com/462.html
  • alpine
  • docker
  • JAVA环境
k8s

Kubernetes集群搭建

环境说明 操作系统:CentOS7.4 64bit 软件版本:kubernetes-v1.9.9、etcd-v3.3.8、flannel-v0.10.0 下载地址: https://dl.k8s.io...
k8s

Filebeat收集K8S日志

Kubernetes 中比较流行的日志收集解决方案是 Elasticsearch、Logstash和 Kibana(ELK)技术栈,今天来推荐EFK,即Logstash换成filebeat。 切换到E...
匿名

发表评论

匿名网友
确定

拖动滑块以完成验证