0

I am trying to start a Java program in a docker container. After docker-compose build i try to start the program with docker-compose up but get the following error:

Exception in thread "main" java.lang.UnsupportedOperationException: Unable to open DISPLAY

The readme of the progam says: "If you get the error message that the container cannot connect to Xorg (Unable to open DISPLAY) when starting the container, the supplied script "./startup.sh" needs to be executed".

startup.sh:

#!/bin/sh
xhost +local:
docker-compose up
xhost -local:

dockerfile

FROM ubuntu:16.04

RUN apt-get update && apt-get install --assume-yes --no-install-recommends openjfx openjdk-8-jdk maven git

COPY . /opt/Testfolder
WORKDIR /opt/Testfolder/src
RUN mvn package -DskipTests -Dcheckstyle.skip
CMD java -jar program.jar

At what point would i need to execute the startup.sh script? Do i need to add another RUN startup.sh in the dockerfile? Anyone has an idea?

  • Running a GUI application in a Docker container is complex and depends on the host OS; also see [Can you run GUI applications in a Linux Docker container?](https://stackoverflow.com/questions/16296753/can-you-run-gui-applications-in-a-linux-docker-container). You'll probably find this easier to run installing a JVM on the host and running it without Docker. – David Maze Feb 26 '22 at 17:02
  • hi, thanks for the input. i will have a look at this. and yes you are right, that would be much easier. lets assume the readme is right and all i need to do is to execute the startup.sh script. At what point would i need to do this? – bananaconda Feb 26 '22 at 17:13
  • What does the script do? Is this an application you're writing or maintaining, or are you just trying to run it? – David Maze Feb 26 '22 at 17:23
  • What version of JavaFX does that give you? It seems unlikely to be a version that is compatible with Java 8, which is ancient. – James_D Feb 26 '22 at 17:28
  • I am just trying to run it. It can be found here: https://github.com/ByteHamster/PSE I was able to run it locally, but wanted to run it in docker. The project is 5 years old, last time updated in 2017. As it's not my project I am not sure what the script does. – bananaconda Feb 26 '22 at 17:56
  • Contact the authors of the project directly and request their assistance. – jewelsea Feb 27 '22 at 00:48
  • Similar [Getting a javaFX 11 app to work on docker](https://stackoverflow.com/questions/56994260/getting-a-javafx-11-app-to-work-on-docker). – jewelsea Feb 27 '22 at 00:51

1 Answers1

0

If you don't remove xhost permissions it may work. See the following: https://askubuntu.com/questions/1201103/docker-x11-fails-to-open-display