Linux - Dockerfile - JDK
2021/6/9 7:21:01
本文主要是介绍Linux - Dockerfile - JDK,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
# file list [22:43:27 root@centos7 jdk]#tree . ├── Dockerfile ├── jdk-8u291-linux-x64.tar.gz └── profile 0 directories, 3 files # download jdk packages from oracle # copy centos7:/etc/profile , add below 4 lines [22:46:35 root@centos7 jdk]#tail -5 profile export JAVA_HOME=/usr/local/jdk export TOMCAT_HOME=/apps/tomcat export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$TOMCAT_HOME/bin:$PATH export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar # edit Dockerfile [22:47:19 root@centos7 jdk]#cat Dockerfile FROM centos7-base:v2 LABEL maintainer="noise <root@noise.com>" ADD jdk-8u291-linux-x64.tar.gz /usr/local/src RUN ln -s /usr/local/src/jdk1.8.0_291 /usr/local/jdk ADD profile /etc/profile ENV JAVA_HOME /usr/local/jdk ENV JRE_HOME $JAVA_HOME/jre ENV CLASSPATH $JAVA_HOME/lib/:$JRE_HOME/lib/ ENV PATH $PATH:$JAVA_HOME/bin # docker build [22:41:06 root@centos7 jdk]#docker build -t jdk:v2.0 . [22:41:15 root@centos7 jdk]#docker images REPOSITORY TAG IMAGE ID CREATED SIZE jdk v2.0 e1ef0c699afa 4 seconds ago 708MB # docker run to check if jdk is installed successfully [22:41:19 root@centos7 jdk]#docker run -it jdk:v2.0 bash [root@344f5caf88ee /]# java -version java version "1.8.0_291" Java(TM) SE Runtime Environment (build 1.8.0_291-b10) Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode) [root@344f5caf88ee /]# exit exit # push to harbor [22:41:43 root@centos7 jdk]#docker tag jdk:v2.0 10.0.0.101/example/jdk:v2.0 [22:42:43 root@centos7 jdk]#docker push 10.0.0.101/example/jdk:v2.0 The push refers to repository [10.0.0.101/example/jdk] 193267eb9d23: Pushed 9f7b8adad2b1: Pushed 496063d1b0f4: Pushed 7b578e484e37: Pushed 764e12176167: Pushed 034f282942cd: Pushed v2.0: digest: sha256:b7b5863b67bbe0228da549df1b79d8c8a6be62627747d41f843d2e18b160a092 size: 1577
这篇关于Linux - Dockerfile - JDK的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-22项目:远程温湿度检测系统
- 2024-12-21《鸿蒙HarmonyOS应用开发从入门到精通(第2版)》简介
- 2024-12-21后台管理系统开发教程:新手入门全指南
- 2024-12-21后台开发教程:新手入门及实战指南
- 2024-12-21后台综合解决方案教程:新手入门指南
- 2024-12-21接口模块封装教程:新手必备指南
- 2024-12-21请求动作封装教程:新手必看指南
- 2024-12-21RBAC的权限教程:从入门到实践
- 2024-12-21登录鉴权实战:新手入门教程
- 2024-12-21动态权限实战入门指南