[Bug] `Error: JAVA_HOME not set` when using legacy docker
- Dominant language
- Java
- Stars
- 15.3k
- Forks
- 3.8k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 160
Description
### Search before asking
- [X] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar.
### Version
```sh
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
```yml
---
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
...
```
```sh
docker-compose up
```
### What did you expect to see?
start successfully
### What did you see instead?
```log
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:

3.1.1 image:

I test on another machine,
the `JAVA_HOME`, `JAVA_BIN` is empty too,
but it start successfully,
both are aliyun ecs
```sh
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?
- [ ] I'm willing to submit a PR!
Contributor guide
Research direction
Start by reproducing the provided docker-compose setup with the apachepulsar/pulsar:3.1.1 image and compare it with 2.7.0, including the reported host environments. Inspect the container's Java-related environment and startup entry point around the `bin/pulsar standalone` command. Done means the 3.1.1 legacy Docker setup starts successfully without manually setting JAVA_HOME.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, java
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100