I think it is because your hello world app is running in a separate docker container ... in that container localhost does not point to the localhost of the container that the apm server is running in. This is a docker networking issue.... remember every container is its own "host"
I suspect if you just ran your hello world from the actual host command line outside of docker it would probably work
And or read something like this
and change to something like this...
ENTRYPOINT ["/bin/sh", "-c", "java -javaagent:/tmp/elastic-apm-agent.jar -Delastic.apm.service_name=helloworld-service -Delastic.apm.application_packages=com.example -Delastic.apm.server_urls=http://host.docker.internal:8200 -jar /app/helloworld-*.jar"]