How to forward GUI from remote docker container to which I connect via SSH?

1

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
  HostName XXX.XXX.XXX.XXX
  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):

#!/bin/bash

XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
touch $XAUTH
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -

ARG1=${1:-0}
ARG2=${2:-9999}
NV_GPU=$ARG1

nvidia-docker run \
--shm-size 8G \
-p $ARG2:$ARG2 \
--env="DISPLAY" \
--env="XAUTHORITY=${XAUTH}" \
--env="QT_X11_NO_MITSHM=1" \
--env="CUDA_VISIBLE_DEVICES=0" \
--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

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

spaceinvader

Posted 2019-09-08T11:45:46.803

Reputation: 11

No answers