Sunday, February 7, 2021

Create Centos 8 Oracle JDK Docker image

HOWTO

 

Download Oracle JDK RPM from https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

 

GitHub repo https://github.com/dveselka/weblogic/tree/master/docker-oracle-java-8

Docker file

 

[dave@dave docker-oracle-java-8]$ more Dockerfile 
FROM centos:8

ADD jdk-8u231-linux-x64.rpm jdk-8u231-linux-x64.rpm

RUN dnf -y  install jdk-8u231-linux-x64.rpm

 

 

Build Docker image 

[dave@dave docker-oracle-java-8]$ docker build -t dveselka/oracle-jdk-8 .
Sending build context to Docker daemon  178.6MB
Step 1/3 : FROM centos:8
 ---> 300e315adb2f
Step 2/3 : ADD jdk-8u231-linux-x64.rpm jdk-8u231-linux-x64.rpm
 ---> e08cec58130d
Step 3/3 : RUN dnf -y  install jdk-8u231-linux-x64.rpm
 ---> Running in edde270eb14b
CentOS Linux 8 - AppStream                      2.8 MB/s | 6.3 MB     00:02    
CentOS Linux 8 - BaseOS                         2.5 MB/s | 2.3 MB     00:00    
CentOS Linux 8 - Extras                          16 kB/s | 8.6 kB     00:00    
Dependencies resolved.
================================================================================
 Package      Architecture Version                     Repository          Size
================================================================================
Installing:
 jdk1.8       x86_64       2000:1.8.0_231-fcs          @commandline       170 M

Transaction Summary
================================================================================
Install  1 Package

Total size: 170 M
Installed size: 294 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Installing       : jdk1.8-2000:1.8.0_231-fcs.x86_64                       1/1 
  Running scriptlet: jdk1.8-2000:1.8.0_231-fcs.x86_64                       1/1 
Unpacking JAR files...
    tools.jar...
    plugin.jar...
    javaws.jar...
    deploy.jar...
    rt.jar...
    jsse.jar...
    charsets.jar...
    localedata.jar...

  Verifying        : jdk1.8-2000:1.8.0_231-fcs.x86_64                       1/1 

Installed:
  jdk1.8-2000:1.8.0_231-fcs.x86_64                                              

Complete!
Removing intermediate container edde270eb14b
 ---> bec32556adc7
Successfully built bec32556adc7
Successfully tagged dveselka/oracle-jdk-8:latest

 

Created image

 

[dave@dave docker-oracle-java-8]$ pwd
/git/weblogic/docker-oracle-java-8
[dave@dave docker-oracle-java-8]$ ls -1
Dockerfile
jdk-8u231-linux-x64.rpm
[dave@dave docker-oracle-java-8]$ docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
dveselka/oracle-jdk-8   latest              bec32556adc7        3 minutes ago       799MB

 

Java inside running container

 

[dave@dave docker-oracle-java-8]$ docker run -it dveselka/oracle-jdk-8
[root@f679c2746165 /]# java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)

[root@f679c2746165 /]# ls -l /usr/java
total 4
lrwxrwxrwx. 1 root root   16 Feb  7 09:53 default -> /usr/java/latest
drwxr-xr-x. 8 root root 4096 Feb  7 09:53 jdk1.8.0_231-amd64
lrwxrwxrwx. 1 root root   28 Feb  7 09:53 latest -> /usr/java/jdk1.8.0_231-amd64
[root@f679c2746165 /]# more /etc/redhat-release 
CentOS Linux release 8.3.2011


No comments:

Post a Comment