【问题标题】:Find and change the value of JAVA_HOME in centos/wildfly docker image在 centos/wildfly docker 镜像中查找并更改 JAVA_HOME 的值
【发布时间】:2019-10-13 15:10:56
【问题描述】:

我刚开始使用 docker,所以这可能是一个概念错误 -

我从 Docker Hub 下载了centos/wildfly 映像,并想更改此服务器的 JDK 版本。
但是,我在 wildfly 配置文件中的任何地方都找不到 JAVA_HOME 值,并且 usr 中没有任何 java 文件夹
对于这个设置和图像,它从哪里提取 JDK 路径?有没有办法访问它并希望改变它?

【问题讨论】:

  • 更改 JDK 版本/位置需要构建您自己的 Wildfly 容器。 JDK 由我期望的下面的一层提供(未选中)。将另一个 JDK 更改/添加到容器会扩展容器的大小。
  • @Konrad 这是该图像的 dokcerfile 中的行:RUN yum -y install tar java-1.7.0-openjdk-devel saxon \ augeas bsdtar shadow-utils && yum clean all
  • @Arapel 请检查我是否能够使用 JDK-1.8.0 构建映像。希望这将有助于接受它,如果它很好,让我知道是否有任何问题。

标签: java docker wildfly centos7


【解决方案1】:

如果查看 centos/wildly 的官方仓库,你会发现类似

RUN yum -y install tar java-1.7.0-openjdk-devel

wildfly/centos7/Dockerfile

所以你不需要修改现有的镜像,只需构建你自己的镜像,在 Dockerfile 中更新 JDK 版本,构建它并从你自己的镜像运行容器。

创建您自己的 Dockerfile 并运行以下命令。

docker build --tag=centos/wildfly-admin-jdk-1.8 .

docker run -it -p 9990:9990 centos/wildfly-admin-jdk-1.8

这里是 JDK-1.8.0 的 Dockerfile

# Use latest Fedora image as the base
FROM centos:latest
MAINTAINER http://www.centos.org

LABEL Vendor="CentOS"
LABEL License=GPLv2
LABEL Version=8.2.0.Final


# Update base image
RUN yum -y update && yum clean all

# xmlstarlet is useful when modifying attributes/elements
# saxon can be used to execute configuration transformation using XSLT
# augeas is a great tool to edit any configuration files (XML too)
# bsdtar can be used to unpack zip files using pipes
RUN yum -y install tar java-1.8.0-openjdk-devel saxon \ 
augeas bsdtar shadow-utils && yum clean all

# Set the WILDFLY_VERSION env variable
ENV WILDFLY_VERSION 8.2.0.Final

# Create the wildfly user and group
RUN groupadd -r wildfly -g 433 && useradd -u 431 -r -g wildfly -d /opt/wildfly -s /sbin/nologin -c "WildFly user" wildfly

# Create directory to extract tar file to
RUN mkdir /opt/wildfly-$WILDFLY_VERSION

# Add the WildFly distribution to /opt, and make wildfly the owner of the extracted tar content
RUN cd /opt && curl http://download.jboss.org/wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.tar.gz | tar zx && chown -R wildfly:wildfly /opt/wildfly-$WILDFLY_VERSION

# Make sure the distribution is available from a well-known place
RUN ln -s /opt/wildfly-$WILDFLY_VERSION /opt/wildfly && chown -R wildfly:wildfly /opt/wildfly

# Set the JBOSS_HOME env variable
ENV JBOSS_HOME /opt/wildfly

# Expose the ports we're interested in
EXPOSE 8080 9990

# Run everything below as the wildfly user
USER wildfly

# Set the default command to run on boot
# This will boot WildFly in the standalone mode and bind to all interface
CMD ["/opt/wildfly/bin/standalone.sh", "-c", "standalone-full.xml", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-26
    • 2018-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多