当我使用Ubuntu 14.04 (IP: a.b.c.d)工作时,我想执行一个程序(p.e.firefox),并获得图形输出,我在docker容器中启动一个shell,并在这个shell中执行:
DISPLAY=a.b.c.d:0 firefox
另一方面,当我在家里,需要在工作pc中运行程序,并在具有私有IP地址(NATed)的家用pc中获得输出时,我连接:
$ ssh -X work-pc
然后,我在该shell中运行该程序,并在本地获得输出。
是否有一种方法可以通过"ssh -X“隧道将docker容器的输出重定向到home?
我知道我可以在容器中安装ssh服务器,将work-pc中的端口重定向到容器的端口22,将home-pc本地端口重定向到该work-pc端口(使用ssh -L端口:host: port work-pc),然后使用"ssh -X“从home-pc连接到容器以获得家里的输出,但我想知道是否有其他方法。
谢谢。
发布于 2019-06-20 14:38:47
我按照https://dzone.com/articles/docker-x11-client-via-ssh上的说明做了一些事情。
我的docker-compose有:
version: "3.7"
services:
rhel:
privileged: true
build:
context: /home/mpawlowsky/docker
dockerfile: Dockerfile
volumes:
- /tmp/.x11-unix:/tmp/.x11-unix
- /home/mpawlowsky/.Xauthority:/root/.Xauthority:rw
cap_add:
- NET_ADMIN
- NET_RAW
environment:
- DISPLAY
network_mode: host
我启动容器并在其中运行:
$ docker-compose up -d
$ docker exec -it rhel /bin/bash
$ firefox
https://stackoverflow.com/questions/27626679
复制相似问题