apache / pulsar

Apache Pulsar - distributed pub-sub messaging system
https://pulsar.apache.org/
Apache License 2.0
14.2k stars 3.58k forks source link

[Bug] `Error: JAVA_HOME not set` when using legacy docker #21815

Open youzipi opened 10 months ago

youzipi commented 10 months ago

Search before asking

Version

docker images
>
REPOSITORY                      TAG       IMAGE ID       CREATED         SIZE
apachepulsar/pulsar             3.1.1     e1ce95d6fa9f   3 months ago    1.18GB

cat /proc/version
>
Linux version 3.10.0-1160.6.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Tue Nov 17 13:59:11 UTC 2020

Minimal reproduce step

---
version: "3.7"
services:
  pulsar:
    image: apachepulsar/pulsar:3.1.1
    environment:
    - PULSAR_MEM=-Xms512m -Xmx512m -XX:MaxDirectMemorySize=1g
    - PULSAR_PREFIX_defaultRetentionTimeInMinutes=14400
    - PULSAR_PREFIX_defaultRetentionSizeInMB=1000
    - PF_ENV_DEBUG=1
    command: >
      /bin/bash -c
      "pwd
      && echo 'JAVA_HOME='$JAVA_HOME
      && echo 'JAVA_BIN='$JAVA_BIN
      && echo $(which java)
      && ls -alh /usr/local
      && bin/pulsar standalone --advertised-address standalone -nss"
    hostname: pulsar
    ports:
    - 8093:8080
    - 6651:6650
...
docker-compose up

What did you expect to see?

start successfully

What did you see instead?

pulsar_1  | Error: JAVA_HOME not set, and no java executable found in /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin.
pulsar_new_pulsar_1 exited with code 1

Anything else?

i check the file

2.7.0 image: total 44K

3.1.1 image: drwxr-xr-x 1 root root 4 0K Aug 16 0203

I test on another machine, the JAVA_HOME, JAVA_BIN is empty too, but it start successfully, both are aliyun ecs

cat /proc/version
>
Linux version 3.10.0-1160.71.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Tue Jun 28 15:37:28 UTC 2022

Are you willing to submit a PR?

youzipi commented 10 months ago
which java
>
/usr/bin/java

java --version
>
openjdk 17.0.8.1 2023-08-24
OpenJDK Runtime Environment Temurin-17.0.8.1+1 (build 17.0.8.1+1)
OpenJDK 64-Bit Server VM Temurin-17.0.8.1+1 (build 17.0.8.1+1, mixed mode, sharing)
which java
>
[empty]

java --version
>
[0.004s][warning][os,thread] Failed to start thread "GC Thread#0" - pthread_create failed (EPERM) for attributes: stacksize: 1024k, guardsize: 4k, detached.
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Cannot create worker GC thread. Out of system resources.
# An error report file with more information is saved as:
# /pulsar/hs_err_pid37.log
youzipi commented 10 months ago

seems docker problem, after upgrade the docker version, it fix.

java is exists, but $(which java) return null, java command will throw insufficient memory err.

 sudo docker version
Client: Docker Engine - Community
 Version:           20.10.0
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        7287ab3
 Built:             Tue Dec  8 18:57:35 2020
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.0
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       eeddea2
  Built:            Tue Dec  8 18:56:55 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.3
  GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc:
  Version:          1.0.0-rc92
  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
sudo docker version
Client: Docker Engine - Community
 Version:           24.0.7
 API version:       1.43
 Go version:        go1.20.10
 Git commit:        afdd53b
 Built:             Thu Oct 26 09:11:35 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.7
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.10
  Git commit:       311b9ff
  Built:            Thu Oct 26 09:10:36 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.26
  GitCommit:        3dd1e886e55dd695541fdcd67420c2888645a495
 runc:
  Version:          1.1.10
  GitCommit:        v1.1.10-0-g18a0cb0
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
youzipi commented 10 months ago

similar issue: https://github.com/keycloak/keycloak/issues/17404