Closed amalkapathirage closed 4 years ago
@amalkapathirage Looks to me you are trying to create a Corretto 8 JRE image right?
Instead of pulling the rpm from the Corretto download page, a more convenient way is to use the amazon-linux-extra rpm repo described here. If you only need JRE, in your dockerfile, try:
FROM amazonlinux:2
RUN amazon-linux-extras enable corretto8 && \
yum install -y java-1.8.0-amazon-corretto && yum clean all
Possible but its 417MB
This is the Docker file used earlier ...this is 163MB why its looking for the dependancies mentioned.
FROM amazonlinux:2
ARG rpm_x64=java-1.8.0-amazon-corretto-1.8.0_232.b09-1.amzn2.0.1.x86_64.rpm ARG path_x64=https://d3pxv6yz143wms.cloudfront.net/8.232.09.1 ARG key_x64=E8EB406377AD2B9E9A4765D19CB3BC6FF6C9FC19
ARG rpm_aarch64=java-1.8.0-amazon-corretto-1.8.0_232.b09-1.amzn2.0.1.aarch64.rpm ARG path_aarch64=https://d3pxv6yz143wms.cloudfront.net/8.232.09.1 ARG key_aarch64=E8EB406377AD2B9E9A4765D19CB3BC6FF6C9FC19
RUN set -eux; \ case "$(uname -p)" in \ x86_64) rpm=$rpm_x64; path=$path_x64; key=$key_x64 ;; \ aarch64) rpm=$rpm_aarch64; path=$path_aarch64; key=$key_aarch64 ;; \ *) echo >&2 "Unsupported architecture $(uname -p)."; exit 1 ;; \ esac; \ \ curl -O $path/$rpm \ && export GNUPGHOME="$(mktemp -d)" \ && gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys $key \ && gpg --armor --export $key > corretto.asc \ && rpm --import corretto.asc \ && rpm -K $rpm \ && rpm -i $rpm \ && rm -r $GNUPGHOME corretto.asc $rpm \ && yum install -y fontconfig \ && yum clean all
ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto
@amalkapathirage Modify your Dockerfile:
- && rpm -i $rpm \
+ && yum localinstall -y $rpm \
I do not want to disappoint you but this is equivalent to the installation using amazon-linux-extras.
I see you want to reduce the Corretto docker image size however this is not easy for now. You may find the amazon linux JRE rpm significantly smaller than the generic linux JDK rpm. This is because the Amazon Linux version of Corretto is configured to depend on the system libraries therefore it is smaller but requires installing dependency packages during the yum installation. The generic Linux however, even static links libstdc++ & libgcc, therefore the rpm itself is much bigger. As my teammate mentioned in another issue, we are reconsidering the packaging of the generic Linux rpm. i.e., we are considering splitting the fat rpm into JRE & JDK rpms. You can follow other related issues: corretto-8#45 & corretto-8#193.
still it is 417MB. The issue here is it fails when installing dependency packages during the yum installation. any reason for that ?
@amalkapathirage Please note the difference between rpm --install (or rpm -i)
and yum install
(or in this case, yum localinstall
). Quote from a stackexchange answer:
The major differences between YUM and RPM are that yum knows how to resolve dependencies and can source these additional packages when doing its work. Though rpm can alert you to these dependencies, it is unable to source additional packages.
An issue in Corretto 8 Docker Images
Changes to the docker file FROM amazonlinux:2
x86_64 args
ARG rpm_x64=java-1.8.0-amazon-corretto-1.8.0_232.b09-1.amzn2.0.1.x86_64.rpm
aarch64 args
ARG rpm_aarch64=java-1.8.0-amazon-corretto-1.8.0_232.b09-1.amzn2.0.1.aarch64.rpm
Failed dependencies:
Get the following error when try to build the docker image
error: Failed dependencies: dejavu-sans-fonts is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 dejavu-sans-mono-fonts is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 dejavu-serif-fonts is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 giflib is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 jpackage-utils is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libGL.so.1()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libX11.so.6()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libXext.so.6()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libXi.so.6()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libXrender.so.1()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libXtst.so.6()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libXxf86vm.so.1()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libasound.so.2()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libasound.so.2(ALSA_0.9)(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libasound.so.2(ALSA_0.9.0rc4)(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libatk-1.0.so.0()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libcairo.so.2()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libfontconfig.so.1()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libfreetype.so.6()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libgdk-x11-2.0.so.0()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libgdk_pixbuf-2.0.so.0()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libgif.so.4()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libgtk-x11-2.0.so.0()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libpango-1.0.so.0()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libpangocairo-1.0.so.0()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 libpangoft2-1.0.so.0()(64bit) is needed by java-1.8.0-amazon-corretto-1:1.8.0_232.b09-1.amzn2.0.1.x86_64 The command '/bin/sh -c set -eux; case "$(uname -p)" in x86_64) rpm=$rpm_x64; path=$path_x64; key=$key_x64 ;; aarch64) rpm=$rpm_aarch64; path=$path_aarch64; key=$key_aarch64 ;; *) echo >&2 "Unsupported architecture $(uname -p)."; exit 1 ;; esac; curl -O $path/$rpm && export GNUPGHOME="$(mktemp -d)" && gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys $key && gpg --armor --export $key > corretto.asc && rpm --import corretto.asc && rpm -K $rpm && rpm -i $rpm && rm -r $GNUPGHOME corretto.asc $rpm && yum install -y fontconfig && yum clean all' returned a non-zero code: 1