dlsniper / docker-intellij

Docker image for IntelliJ IDEA Community, Go and Go plugin
MIT License
29 stars 22 forks source link

Can't connect to X11 window server using ':0' as the value of the DISPLAY variable #7

Open breandan opened 6 years ago

breandan commented 6 years ago

I received the following error when running dlsniper/docker-intellij according to the readme:

$ docker run -ti \
           --net="host" \
           --privileged=true \
           -e DISPLAY=${DISPLAY} \
           -v /tmp/.X11-unix:/tmp/.X11-unix \
           -v ${HOME}/.IdeaIC2016.1_docker:/home/developer/.IdeaIC2016.1 \
           -v ${GOPATH}:/home/developer/go \
           dlsniper/docker-intellij

No protocol specified

Start Failed: Failed to initialize graphics environment

java.awt.AWTError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
    at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
    at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65)
    at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:115)
...

To resolve this, I ran sudo xhost + (note this method is very insecure, as it allows all incoming X connections).

DrStoop commented 4 years ago

I receive the same error when trying to run intellij programs as sudoer in the container. In case this is causing your error, you can avoid it by running the container as non-sudoer.

To run as specified non-sudoer-user (e.g. developer) in the container (user must exist in the image/container), then you can simply add --user developer to you docker run... command.