joernio / joern

Open-source code analysis platform for C/C++/Java/Binary/Javascript/Python/Kotlin based on code property graphs. Discord https://discord.gg/vv4MH284Hc
https://joern.io/
Apache License 2.0
2.05k stars 279 forks source link

[Bug] No java installations was detected in Docker #3209

Open m2kar opened 1 year ago

m2kar commented 1 year ago

Describe the bug When run joern docker image from ghcr.io, show No java installations was detected.

To Reproduce Steps to reproduce the behavior:

  1. docker run --rm -it -v /tmp:/tmp -v $(pwd):/app:rw -w /app -t ghcr.io/joernio/joern:nightly joern
  2. See error
Unable to find image 'ghcr.io/joernio/joern:nightly' locally
nightly: Pulling from joernio/joern
c5196fa8a240: Pull complete
d71d0ac89aef: Pull complete
ab5880af1f3e: Pull complete
Digest: sha256:c4337f67df9f0f9ce073a1184b8857e1b013f164dc99a454bbbff7891e6b825c
Status: Downloaded newer image for ghcr.io/joernio/joern:nightly

No java installations was detected.
Please go to http://www.java.com/getjava/ and download

Expected behavior run joern

Screenshots If applicable, add screenshots to help explain your problem. image

Desktop (please complete the following information):

prabhu commented 1 year ago

@m2kar This is strange.

Could you share the output of?

docker run --rm -it -v /tmp:/tmp -v $(pwd):/app:rw -w /app -t ghcr.io/joernio/joern:nightly java -version
docker run --rm -it -v /tmp:/tmp -v $(pwd):/app:rw -w /app -t ghcr.io/joernio/joern:nightly echo $JAVA_HOME

As a workaround, start the bash shell and then type joern

docker run --rm -it -v /tmp:/tmp -v $(pwd):/app:rw -w /app -t ghcr.io/joernio/joern:nightly /bin/bash
joern
m2kar commented 1 year ago

Here are the output of the shell commands:

  1. 
    $ sudo docker run --rm -it -v /tmp:/tmp -v $(pwd):/app:rw -w /app -t ghcr.io/joernio/joern:nightly java -version
    Unable to find image 'ghcr.io/joernio/joern:nightly' locally
    nightly: Pulling from joernio/joern
    c5196fa8a240: Pull complete 
    537fdc407eb3: Pull complete 
    7f668f01f2e2: Pull complete 
    Digest: sha256:e1dd6e483ef847150234f7220f5f6a1334df0e7430ff094fbdc43798ec88897b
    Status: Downloaded newer image for ghcr.io/joernio/joern:nightly
    [0.014s][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:
    # /app/hs_err_pid1.log
    failed to resize tty, using default size
2. 

$ sudo docker run --rm -it -v /tmp:/tmp -v $(pwd):/app:rw -w /app -t ghcr.io/joernio/joern:nightly echo $JAVA_HOME

``` 3. ``` $ sudo docker run --rm -it -v /tmp:/tmp -v $(pwd):/app:rw -w /app -t ghcr.io/joernio/joern:nightly /bin/bash [root@a17c3c7f1c0a app]# joern No java installations was detected. Please go to http://www.java.com/getjava/ and download [root@a17c3c7f1c0a app]# ```
prabhu commented 1 year ago

@m2kar Could you try it on a recent version of Linux with sufficient memory?

m2kar commented 1 year ago

The memory is sufficient.

$ free -m
              total        used        free      shared  buff/cache   available
Mem:          17275        3066        9277          56        4930       13855
Swap:          2047           0        2047

The linux version:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:    18.04
Codename:   bionic
prabhu commented 1 year ago

@m2kar Kernel 4 is quite old. Do you have ubuntu 22.04?

m2kar commented 1 year ago

I try on another operation system, and this docker works.

$ lsb_release -a
LSB Version:    n/a
Distributor ID: ManjaroLinux
Description:    Manjaro Linux
Release:        23.0.0
Codename:       Uranos
$ uname -a
Linux SEC-T440s 6.1.44-1-MANJARO #1 SMP PREEMPT_DYNAMIC Wed Aug  9 09:02:26 UTC 2023 x86_64 GNU/Linux

$ sudo docker run --rm -it -v /tmp:/tmp -v $(pwd):/app:rw -w /app -t ghcr.io/joernio/joern:nightly java -version
openjdk version "17.0.8" 2023-07-18 LTS
OpenJDK Runtime Environment (Red_Hat-17.0.8.0.7-1) (build 17.0.8+7-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-17.0.8.0.7-1) (build 17.0.8+7-LTS, mixed mode, sharing)

There may be some incompatibility within the older version of Docker or the older version of the Linux kernel.