Don't set DISPLAY in the Dockerfile — instead, pass it at runtime to ensure it matches your host system.
and this will help you
https://github.com/Kinsella-Consulting/docker-java-swing?tab=readme-ov-file
https://learnwell.medium.com/how-to-dockerize-a-java-gui-application-bce560abf62a