I have a MacBook that I use as client machine and connect to remote Ubuntu server where I have a running docker container. In docker container I have an application which use opencv that create an output window of video capture device.

When I launch that application in docker container I got an error:

Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused

(output:15): Gtk-WARNING **: cannot open display: localhost:10.0

I tried to change DISPLAY env variable to :0 but result is the same.

I connect via VSCode Remote SSH plugin which can open a project folder from remote server using ssh config:

Host hostname
  User yegor
  IdentityFile ~/.ssh/id_rsa
  ForwardX11 yes
  ForwardX11Trusted yes

On remote server I launch a docker container in following (I remade an exampl for my own):


touch $XAUTH
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -


nvidia-docker run \
--shm-size 8G \
-p $ARG2:$ARG2 \
--env="DISPLAY" \
--env="QT_X11_NO_MITSHM=1" \
--volume=$XSOCK:$XSOCK:rw \
--volume=$XAUTH:$XAUTH:rw \
--device=/dev/video0:/dev/video0 \
--name libtorch \
--mount type=bind,source="$PWD",target=/app \
--net=host \
-it --rm \
yegor/libtorch:cuda10.0-ubuntu16.04 bash

What I want is just get an OpenCV window on my Mac.

  1. MacBook -> remote server -> remote server run a container with app
  2. App create a frame -> I get it on my computer

Maybe my english is not very well and it is my first question on Stack Overflow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.