How Do You Create a Docker Image That Has Java 10 in It?

Problem scenario
You want to create Docker containers with Java 9.  How do you create a Docker image to make containers with Java 9 installed in them?

These directions were updated on 12/26/18.

Solution
Prerequisite

This assumes that you have Docker installed. If you need assistance with this, see these postings depending on your operating system:

Debian/Ubuntu
CentOS/Fedora/RHEL
SUSE

Procedures
1.  Create a filed called Dockerfile with the following content:

FROM ubuntu:latest
MAINTAINER NAME EMAIL

RUN apt-get -y update && apt-get -y upgrade && apt-get install -y build-essential openjdk-11-jre-headless

2.  Run this command: 

docker build -t "java:java" .

# You should see an image ID.  If you need to find out later, use "docker images" to find it.

# You are now done.

3.  This step is optional if you want to create a container and enter it.  Run these commands:

docker create -it <ImageID> bash

# You should see a container ID.  If you need to find out later, use "docker ps -a"

docker start <containerID>

docker exec -it <containerID> bash

If the above directions do not work with RHEL, please post a comment. You do not need to use your real name.

Leave a comment

Your email address will not be published. Required fields are marked *