admin管理员组

文章数量:1305102

I am using Flink 1.20.0 with Java 11. I have downloaded JDK 17 locally using jdk-17.0.12_linux-aarch64_bin.tar.gz, unzipped it, and during the creation of a container using Podman, I am copying the JDK to the opt directory. I want to set the path for the new JDK 17 permanently. I am able to set the path for the session only.

I have tried using the -e option with Podman when creating the container and setting the variables, but the container is not starting. This might be because the jdk-17.0.12 folder is not present after creating the container.

podman run -d -e JAVA_HOME=/opt/$JAVA_DIR_NAME/jdk-17.0.12 -e PATH=/opt/flink/bin:/opt/jdk-17/jdk-17.0.12/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -p 8081:8081 -p 6123:6123 --name testmanager flink:1.20.0 testmanager

I also tried the following commands, but they did not work:

podman exec -it $JOBMANAGER_CONTAINER_NAME bash -c "echo 'export JAVA_HOME=/opt/$JAVA_DIR_NAME/jdk-17.0.12' >> /etc/profile"
podman exec -it $JOBMANAGER_CONTAINER_NAME bash -c "echo 'export PATH=\$JAVA_HOME/bin:\$PATH' >> /etc/profile"
podman exec -it $JOBMANAGER_CONTAINER_NAME bash -c "source /etc/profile"

If I SSH into the container, I can set PATH and JAVA_HOME, but it is only for the session, not permanent. Please help me set PATH and JAVA_HOME permanently for all users and sessions.

I am using Flink 1.20.0 with Java 11. I have downloaded JDK 17 locally using jdk-17.0.12_linux-aarch64_bin.tar.gz, unzipped it, and during the creation of a container using Podman, I am copying the JDK to the opt directory. I want to set the path for the new JDK 17 permanently. I am able to set the path for the session only.

I have tried using the -e option with Podman when creating the container and setting the variables, but the container is not starting. This might be because the jdk-17.0.12 folder is not present after creating the container.

podman run -d -e JAVA_HOME=/opt/$JAVA_DIR_NAME/jdk-17.0.12 -e PATH=/opt/flink/bin:/opt/jdk-17/jdk-17.0.12/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -p 8081:8081 -p 6123:6123 --name testmanager flink:1.20.0 testmanager

I also tried the following commands, but they did not work:

podman exec -it $JOBMANAGER_CONTAINER_NAME bash -c "echo 'export JAVA_HOME=/opt/$JAVA_DIR_NAME/jdk-17.0.12' >> /etc/profile"
podman exec -it $JOBMANAGER_CONTAINER_NAME bash -c "echo 'export PATH=\$JAVA_HOME/bin:\$PATH' >> /etc/profile"
podman exec -it $JOBMANAGER_CONTAINER_NAME bash -c "source /etc/profile"

If I SSH into the container, I can set PATH and JAVA_HOME, but it is only for the session, not permanent. Please help me set PATH and JAVA_HOME permanently for all users and sessions.

Share Improve this question edited Feb 5 at 18:56 Samu Németh 5701 gold badge5 silver badges20 bronze badges asked Feb 4 at 2:04 MiteshMitesh 133 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 0

I have created new image for flink:1.20.0 and Java17.

Use the Flink 1.20.0 image as the base image

FROM flink:1.20.0

Set the directory where Java 17 will be copied

ENV JAVA_HOME=/opt/java17

ENV PATH="$JAVA_HOME/bin:$PATH"

Copy Java 17 files to the /opt directory

COPY jdk-17/jdk-17.0.12 /opt/java17

Verify Java installation (optional)

RUN java -version

本文标签: