skip to Main Content

I am new to docker, and I need help to build corretto 17 alpine linux image.
I have an existing docker file which build java jdk 8 alpine linux image as below.

FROM alpine:3.17

# install software
RUN apk add --no-cache 
    bash 
    openjdk8-jre

How can I add corretto 17 command to this docker file to run my application on corretto 17.

Thanks

2

Answers


  1. Chosen as BEST ANSWER

    I found an aws doc to install Amazon Corretto 17 on Alpine Linux

    below is the command that neet to insert in your docker file to install corretto 17.

    FROM alpine:3.17
        RUN apk add --no-cache &&
                wget -O /etc/apk/keys/amazoncorretto.rsa.pub https://apk.corretto.aws/amazoncorretto.rsa.pub && 
                echo "https://apk.corretto.aws" >> /etc/apk/repositories && 
                apk update &&
                apk add amazon-corretto-17
    

  2. An approach, based on my comment in this answer:

    Use the following to use one of the official Corretto Java images – in this case, using Alpine:

    docker pull amazoncorretto:17-alpine-jdk
    

    and then

    docker run -it amazoncorretto:17-alpine-jdk /bin/sh
    

    Or, if you want a Dockerfile:

    FROM amazoncorretto:17-alpine-jdk
    CMD ["/usr/bin/java", "--version"]
    

    If I build the image using this…

    docker build -t whateveryouwant .
    

    …then I can run it with:

    docker run whateveryouwant 
    

    And the run output is:

    openjdk 17.0.6 2023-01-17 LTS
    OpenJDK Runtime Environment Corretto-17.0.6.10.1 (build 17.0.6+10-LTS)
    OpenJDK 64-Bit Server VM Corretto-17.0.6.10.1 (build 17.0.6+10-LTS, mixed mode, sharing)
    

    This obviously doesn’t do anything useful, except to show the Java details.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search