Amazon Corretto 8
User Guide

Getting Started with Amazon Corretto 8 on Docker images.

This topic describes how to build and launch a Docker image that uses Amazon Corretto 8. You must the latest version of Docker installed.

Build a Docker image with Amazon Corretto 8

Run the following command to build an image that uses Amazon Corretto 8.

docker build -t amazon-corretto-8

After the command completes, you have an image called amazon-corretto-8.

To launch this image locally, run the following command.

docker run -it amazon-corretto-8

You can also push this image to Amazon ECR. See the Pushing an Image topic in the Amazon Elastic Container Registry User Guide for details.

Create a new Docker image

You can create a new Docker image using Amazon Corretto 8 Docker image as the parent image.

  1. Create a Dockerfile with the following content.

    FROM amazon-corretto-8 RUN echo $' \ public class Hello { \ public static void main(String[] args) { \ System.out.println("Welcome to Amazon Corretto!"); \ } \ }' > RUN javac CMD ["java", "Hello"]
  2. Build the new image.

    docker build -t hello-app .
  3. Run the new image.

    docker run hello-app

    You will get the following output.

    Welcome to Amazon Corretto!