I want to run a ssh port forwarding command (that should open inside a new terminal window or an equivalent) from inside a docker container. I have a python script that does this perfectly on my local ubuntu.
import os
command = "ssh -4 -N -L 322:localhost:322 toing@localhost -p 654"
os.system("gnome-terminal -e 'bash -c \"" + command + ";bash\"'")
However when I try this command inside a docker container, I get the following error:
Option “-e” is deprecated and might be removed in a later version of gnome-terminal.
Use “-- ” to terminate the options and put the command line to execute after it.
Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-XETYD1whMB: Connection refused
Failed to load module "canberra-gtk-module"
Failed to load module "canberra-gtk-module"
I am running the docker image with the following command (the display is really for another process in the script):
docker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -p 8090:8090 xxxxxxx
I also tried running the same command inside the python terminal inside the container when it is running but got the following response:
>>> os.system("gnome-terminal -e 'bash -c \"" + command + ";bash\"'")
# Option “-e” is deprecated and might be removed in a later version of gnome-terminal.
# Use “-- ” to terminate the options and put the command line to execute after it.
# Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-XETYD1whMB: Connection refused
# Failed to load module "canberra-gtk-module"
# Failed to load module "canberra-gtk-module"
# Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: Failed to execute child process “dbus-launch” (No such file or directory)
256
I need this open terminal to be running in the background, How can I achieve this?