New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use -e DISPLAY flag on osx? #8710

Closed
sindhus opened this Issue Oct 22, 2014 · 108 comments

Comments

Projects
None yet
@sindhus
Contributor

sindhus commented Oct 22, 2014

I am running boot2docker on OSX 10.10

I have a simple docker image, the dockerfile is:

FROM base/archlinux
RUN pacman -Syu --noconfirm --noprogress 
RUN pacman -S --noprogress --noconfirm firefox

I know that one can use VNC (method: install VNC in image, forward ports, access using VNC on osx etc) and I do not want to use VNC if it's possible to load the GUI application in the container to the host's display using the -e DISPLAY flag. I ran docker run -ti --rm -e DISPLAY -v /tmp/.X11-unix/tmp/.X11-unix arch/firefox and got:

Error: cannot open display: /private/tmp/com.apple.launchd.TDD8jmIe6P/org.macosforge.xquartz:0

Any help is appreciated! Thanks

@jessfraz

This comment has been minimized.

Show comment
Hide comment
@jessfraz

jessfraz Oct 22, 2014

Contributor

So since boot2docker is running docker in a virtualbox, there are going to be a few extra configurations that need to happen...
I think what you need is to add X11 forwarding to the virtualbox, I will try out some solutions.
I'm a pretty big fan of bind mounting the X11 socket so it would be cool if it was just as easy for boot2docker users :)

Contributor

jessfraz commented Oct 22, 2014

So since boot2docker is running docker in a virtualbox, there are going to be a few extra configurations that need to happen...
I think what you need is to add X11 forwarding to the virtualbox, I will try out some solutions.
I'm a pretty big fan of bind mounting the X11 socket so it would be cool if it was just as easy for boot2docker users :)

@jessfraz

This comment has been minimized.

Show comment
Hide comment
@jessfraz

jessfraz Oct 24, 2014

Contributor

Yeah so I think VNC is your best option here... you could ssh into the box and enable X11 forwarding as seen here http://oroborosx.sourceforge.net/remotex.html
BUT I hate to say it the awesomeness for bind mounting the X11 sock is really best suited on a linux machine, seeing as it does not require a remote machine (virtualbox), thats really the use case for it. So I am going to close this because we don't plan on supporting something as complicated as bind mounting X11 from osx to a remote server.

Contributor

jessfraz commented Oct 24, 2014

Yeah so I think VNC is your best option here... you could ssh into the box and enable X11 forwarding as seen here http://oroborosx.sourceforge.net/remotex.html
BUT I hate to say it the awesomeness for bind mounting the X11 sock is really best suited on a linux machine, seeing as it does not require a remote machine (virtualbox), thats really the use case for it. So I am going to close this because we don't plan on supporting something as complicated as bind mounting X11 from osx to a remote server.

@jessfraz jessfraz closed this Oct 24, 2014

@tianon

This comment has been minimized.

Show comment
Hide comment
@tianon

tianon Oct 24, 2014

Member

Oh c'mon - where's your sense of adventure? Surely something magical could be done with boot2docker ssh -X ? 😈

Member

tianon commented Oct 24, 2014

Oh c'mon - where's your sense of adventure? Surely something magical could be done with boot2docker ssh -X ? 😈

@jessfraz

This comment has been minimized.

Show comment
Hide comment
@jessfraz

jessfraz Oct 24, 2014

Contributor

I mean I am still going to try and find a solution in my freetime for fun ;) , but just to clear up it will be more of a hack than a fully supported docker feature :)

Contributor

jessfraz commented Oct 24, 2014

I mean I am still going to try and find a solution in my freetime for fun ;) , but just to clear up it will be more of a hack than a fully supported docker feature :)

@tianon

This comment has been minimized.

Show comment
Hide comment
@tianon

tianon Oct 24, 2014

Member

Hahaha, even the Linux version is truly a hack (but a really cool one).
Until we have "docker run -X", this is all "hack land". :D

Member

tianon commented Oct 24, 2014

Hahaha, even the Linux version is truly a hack (but a really cool one).
Until we have "docker run -X", this is all "hack land". :D

@jessfraz

This comment has been minimized.

Show comment
Hide comment
@jessfraz

jessfraz Oct 24, 2014

Contributor

thats what makes it sooooo cool

Contributor

jessfraz commented Oct 24, 2014

thats what makes it sooooo cool

@cpuguy83

This comment has been minimized.

Show comment
Hide comment
@cpuguy83

cpuguy83 Oct 24, 2014

Contributor

Yeah, I haven't been able to get ssh -X (or -Y) to work on boot2docker at all.
On a debian host I can, of course, get ssh -X to work, but keep getting auth errors trying to start an x11 app in a container :(
Too bad you can't just bind-mount the osx socket in, that'd be awesome.

Contributor

cpuguy83 commented Oct 24, 2014

Yeah, I haven't been able to get ssh -X (or -Y) to work on boot2docker at all.
On a debian host I can, of course, get ssh -X to work, but keep getting auth errors trying to start an x11 app in a container :(
Too bad you can't just bind-mount the osx socket in, that'd be awesome.

@jessfraz

This comment has been minimized.

Show comment
Hide comment
@jessfraz

jessfraz Oct 24, 2014

Contributor

now that would actually be straight up magic

On Fri, Oct 24, 2014 at 5:19 AM, Brian Goff notifications@github.com
wrote:

Yeah, I haven't been able to get ssh -X (or -Y) to work on boot2docker at
all.
On a debian host I can, of course, get ssh -X to work, but keep getting
auth errors trying to start an x11 app in a container :(
To bad you can't just bind-mount the osx socket in, that'd be awesome.


Reply to this email directly or view it on GitHub
#8710 (comment).

Contributor

jessfraz commented Oct 24, 2014

now that would actually be straight up magic

On Fri, Oct 24, 2014 at 5:19 AM, Brian Goff notifications@github.com
wrote:

Yeah, I haven't been able to get ssh -X (or -Y) to work on boot2docker at
all.
On a debian host I can, of course, get ssh -X to work, but keep getting
auth errors trying to start an x11 app in a container :(
To bad you can't just bind-mount the osx socket in, that'd be awesome.


Reply to this email directly or view it on GitHub
#8710 (comment).

@slobo

This comment has been minimized.

Show comment
Hide comment
@slobo

slobo Jan 22, 2015

A somewhat crude way to do this:

Start socat to expose local xquartz socket on a TCP port

socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"

Pass the display to container (assuming virtualbox host is available on 192.168.59.3):

docker run -e DISPLAY=192.168.59.3:0 jess/geary

(This is insecure on public networks, add bind, su and range options to socat to limit access.)

screen shot 2015-01-22 at 2 31 28 pm

slobo commented Jan 22, 2015

A somewhat crude way to do this:

Start socat to expose local xquartz socket on a TCP port

socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"

Pass the display to container (assuming virtualbox host is available on 192.168.59.3):

docker run -e DISPLAY=192.168.59.3:0 jess/geary

(This is insecure on public networks, add bind, su and range options to socat to limit access.)

screen shot 2015-01-22 at 2 31 28 pm

@jessfraz

This comment has been minimized.

Show comment
Hide comment
@jessfraz

jessfraz Jan 22, 2015

Contributor

Wow @slobo

  1. I am so awesomely amazed with what you are trying to do here. And with my image :D :D :D
  2. THIS IS AWESOME!!!!
Contributor

jessfraz commented Jan 22, 2015

Wow @slobo

  1. I am so awesomely amazed with what you are trying to do here. And with my image :D :D :D
  2. THIS IS AWESOME!!!!
@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah Jan 22, 2015

Member

Oh, that's really cool!

Member

thaJeztah commented Jan 22, 2015

Oh, that's really cool!

@saulshanabrook

This comment has been minimized.

Show comment
Hide comment
@saulshanabrook

saulshanabrook Feb 3, 2015

In case anyone else is trying, these are my steps to get @slobo's method to work

brew install socat
brew cask install xquartz
open -a XQuartz

socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
# in another window
docker run -e DISPLAY=192.168.59.3:0 jess/geary

saulshanabrook commented Feb 3, 2015

In case anyone else is trying, these are my steps to get @slobo's method to work

brew install socat
brew cask install xquartz
open -a XQuartz

socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
# in another window
docker run -e DISPLAY=192.168.59.3:0 jess/geary
@thiagoeliasr

This comment has been minimized.

Show comment
Hide comment
@thiagoeliasr

thiagoeliasr Feb 3, 2015

It's awesome. Thanks, @slobo

thiagoeliasr commented Feb 3, 2015

It's awesome. Thanks, @slobo

@Krijger

This comment has been minimized.

Show comment
Hide comment
@Krijger

Krijger Feb 17, 2015

Note that the $DISPLAY variable is set in the XQuartz shell. In my case, the value was /private/tmp/com.apple.launchd.HxHsgt3DEr/org.macosforge.xquartz:0

Krijger commented Feb 17, 2015

Note that the $DISPLAY variable is set in the XQuartz shell. In my case, the value was /private/tmp/com.apple.launchd.HxHsgt3DEr/org.macosforge.xquartz:0

@slobo

This comment has been minimized.

Show comment
Hide comment
@slobo

slobo Feb 17, 2015

@Krijger did you run the socat command? That will open a TCP port 6000 to read/write from the XQuartz socket. Then you use docker -e DISPLAY=192.168.59.3:0 so that it uses the newly established TCP bridge, as you currently can't bind the raw socket into the VM.

Unless your installation is special, docker -e DISPLAY=192.168.59.3:0 should instruct X clients in docker to look for X server on 192.168.59.3 port 6000, which socat will then forward to XQuartz socket.

slobo commented Feb 17, 2015

@Krijger did you run the socat command? That will open a TCP port 6000 to read/write from the XQuartz socket. Then you use docker -e DISPLAY=192.168.59.3:0 so that it uses the newly established TCP bridge, as you currently can't bind the raw socket into the VM.

Unless your installation is special, docker -e DISPLAY=192.168.59.3:0 should instruct X clients in docker to look for X server on 192.168.59.3 port 6000, which socat will then forward to XQuartz socket.

@Krijger

This comment has been minimized.

Show comment
Hide comment
@Krijger

Krijger Feb 17, 2015

@slobo yes, I ran the socat command. Only, I ran that in a shell where DISPLAY was not set, thus socat did not forward to the XQuartz socket. The shell inside of X11 does have this variable.
EDIT: after a system restart this variable is set in the normal shell as well (I installed xquartz with brew cask)

After realizing this I changed my question to you in a statement, but you probably replied directly from email and did not see that. Sorry for that.

Krijger commented Feb 17, 2015

@slobo yes, I ran the socat command. Only, I ran that in a shell where DISPLAY was not set, thus socat did not forward to the XQuartz socket. The shell inside of X11 does have this variable.
EDIT: after a system restart this variable is set in the normal shell as well (I installed xquartz with brew cask)

After realizing this I changed my question to you in a statement, but you probably replied directly from email and did not see that. Sorry for that.

@slobo

This comment has been minimized.

Show comment
Hide comment
@slobo

slobo Feb 17, 2015

Ah, makes sense. Cheers.

slobo commented Feb 17, 2015

Ah, makes sense. Cheers.

@Krijger

This comment has been minimized.

Show comment
Hide comment
@Krijger

Krijger Feb 20, 2015

Note that the ip for the display is not $(boot2docker ip), but the address of the vboxnet0 that you can find in ifconfig

vboxnet0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
ether 0a:00:27:00:00:00 
inet 192.168.59.3 netmask 0xffffff00 broadcast 192.168.59.255

Krijger commented Feb 20, 2015

Note that the ip for the display is not $(boot2docker ip), but the address of the vboxnet0 that you can find in ifconfig

vboxnet0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
ether 0a:00:27:00:00:00 
inet 192.168.59.3 netmask 0xffffff00 broadcast 192.168.59.255
@apatawari

This comment has been minimized.

Show comment
Hide comment
@apatawari

apatawari Mar 1, 2015

@slobo
No protocol specified
No protocol specified
Unable to init server: Could not connect: Connection refused

(geary:1): Gtk-WARNING **: cannot open display: 192.168.59.3:0
In my case, I am getting this error. What does this mean exactly?

apatawari commented Mar 1, 2015

@slobo
No protocol specified
No protocol specified
Unable to init server: Could not connect: Connection refused

(geary:1): Gtk-WARNING **: cannot open display: 192.168.59.3:0
In my case, I am getting this error. What does this mean exactly?

@apatawari

This comment has been minimized.

Show comment
Hide comment
@apatawari

apatawari Mar 1, 2015

And on the socat screen,
socat[713] E connect(5, LEN=5 AF=1 "0.0", 5): No such file or directory
is the error.

apatawari commented Mar 1, 2015

And on the socat screen,
socat[713] E connect(5, LEN=5 AF=1 "0.0", 5): No such file or directory
is the error.

@slobo

This comment has been minimized.

Show comment
Hide comment
@slobo

slobo Mar 1, 2015

slobo commented Mar 1, 2015

@apatawari

This comment has been minimized.

Show comment
Hide comment
@apatawari

apatawari Mar 1, 2015

Actually, I realized that after posting the query. But still it gives the same error except no protocol specified is gone. I have attached the Image for the same.
screen shot 2015-03-01 at 10 44 39 am

apatawari commented Mar 1, 2015

Actually, I realized that after posting the query. But still it gives the same error except no protocol specified is gone. I have attached the Image for the same.
screen shot 2015-03-01 at 10 44 39 am

@slobo

This comment has been minimized.

Show comment
Hide comment
@slobo

slobo Mar 1, 2015

slobo commented Mar 1, 2015

@apatawari

This comment has been minimized.

Show comment
Hide comment
@apatawari

apatawari Mar 1, 2015

Yes, In Xterm it does gave me ":0". In terminal app $DISPLAY=0.0, No file
system path, The former error which I got was while ran the socat in
Terminal.app. I did try few things in between, I think that might be the
reason may be it got corrupted. Is their any specific path that I can set
manually or should I try re-installing it.

Yes, In my linux system it did work out with direct docker command just by
mounting the path mounting.

Thanks

Best
Arihant

On Sun, Mar 1, 2015 at 3:03 PM, Slobodan Mišković notifications@github.com
wrote:

Does "echo $DISPLAY" give you ":0" per chance? What if you try it in
Terminal.app, do you get something that looks like file system path? If
so, then try running socat from there.

What we are trying to do is get socat to proxy traffic between TCP port
and
X11 unix socket, so we have to figure out the path to that socket on your
system. On Linux it's often /tmp/.X11-unix/X0, but apple does some funky
stuff with launch daemon to present a socket even when you don't have X11
installed so that they can inform you of missing XQuartz.


Reply to this email directly or view it on GitHub
#8710 (comment).

apatawari commented Mar 1, 2015

Yes, In Xterm it does gave me ":0". In terminal app $DISPLAY=0.0, No file
system path, The former error which I got was while ran the socat in
Terminal.app. I did try few things in between, I think that might be the
reason may be it got corrupted. Is their any specific path that I can set
manually or should I try re-installing it.

Yes, In my linux system it did work out with direct docker command just by
mounting the path mounting.

Thanks

Best
Arihant

On Sun, Mar 1, 2015 at 3:03 PM, Slobodan Mišković notifications@github.com
wrote:

Does "echo $DISPLAY" give you ":0" per chance? What if you try it in
Terminal.app, do you get something that looks like file system path? If
so, then try running socat from there.

What we are trying to do is get socat to proxy traffic between TCP port
and
X11 unix socket, so we have to figure out the path to that socket on your
system. On Linux it's often /tmp/.X11-unix/X0, but apple does some funky
stuff with launch daemon to present a socket even when you don't have X11
installed so that they can inform you of missing XQuartz.


Reply to this email directly or view it on GitHub
#8710 (comment).

@slobo

This comment has been minimized.

Show comment
Hide comment
@slobo

slobo Mar 2, 2015

Try quitting xquartz and terminal.app, and then starting terminal.app again
and inspect $DISPLAY.

On March 1, 2015 3:35:16 PM Arihant Patawari notifications@github.com wrote:

Yes, In Xterm it does gave me ":0". In terminal app $DISPLAY=0.0, No file
system path, The former error which I got was while ran the socat in
Terminal.app. I did try few things in between, I think that might be the
reason may be it got corrupted. Is their any specific path that I can set
manually or should I try re-installing it.

Yes, In my linux system it did work out with direct docker command just by
mounting the path mounting.

Thanks

Best
Arihant

On Sun, Mar 1, 2015 at 3:03 PM, Slobodan Mišković notifications@github.com
wrote:

Does "echo $DISPLAY" give you ":0" per chance? What if you try it in
Terminal.app, do you get something that looks like file system path? If
so, then try running socat from there.

What we are trying to do is get socat to proxy traffic between TCP port
and
X11 unix socket, so we have to figure out the path to that socket on your
system. On Linux it's often /tmp/.X11-unix/X0, but apple does some funky
stuff with launch daemon to present a socket even when you don't have X11
installed so that they can inform you of missing XQuartz.


Reply to this email directly or view it on GitHub
#8710 (comment).


Reply to this email directly or view it on GitHub:
#8710 (comment)

slobo commented Mar 2, 2015

Try quitting xquartz and terminal.app, and then starting terminal.app again
and inspect $DISPLAY.

On March 1, 2015 3:35:16 PM Arihant Patawari notifications@github.com wrote:

Yes, In Xterm it does gave me ":0". In terminal app $DISPLAY=0.0, No file
system path, The former error which I got was while ran the socat in
Terminal.app. I did try few things in between, I think that might be the
reason may be it got corrupted. Is their any specific path that I can set
manually or should I try re-installing it.

Yes, In my linux system it did work out with direct docker command just by
mounting the path mounting.

Thanks

Best
Arihant

On Sun, Mar 1, 2015 at 3:03 PM, Slobodan Mišković notifications@github.com
wrote:

Does "echo $DISPLAY" give you ":0" per chance? What if you try it in
Terminal.app, do you get something that looks like file system path? If
so, then try running socat from there.

What we are trying to do is get socat to proxy traffic between TCP port
and
X11 unix socket, so we have to figure out the path to that socket on your
system. On Linux it's often /tmp/.X11-unix/X0, but apple does some funky
stuff with launch daemon to present a socket even when you don't have X11
installed so that they can inform you of missing XQuartz.


Reply to this email directly or view it on GitHub
#8710 (comment).


Reply to this email directly or view it on GitHub:
#8710 (comment)

@apatawari

This comment has been minimized.

Show comment
Hide comment
@apatawari

apatawari Mar 2, 2015

It remains the same $DISPLAY=0.0
It is also possible to set $DISPLAY variable right?

apatawari commented Mar 2, 2015

It remains the same $DISPLAY=0.0
It is also possible to set $DISPLAY variable right?

@Tset-Noitamotua

This comment has been minimized.

Show comment
Hide comment
@Tset-Noitamotua

Tset-Noitamotua Dec 21, 2016

@qinwf Thanks for Windows 10 hint. It worked for me, too. But I did it a bit different:

  1. choco install xming
  2. put Xming.exe on PATH
  3. Xming.exe :0 -multiwindow -clipboard -ac -from 192.168.178.21 (network IP of my host)
  4. docker run -e DISPLAY=192.168.178.21:0 jess/firefox

It's a bit laggy but works. so cool! Though some errors appear in the console

(firefox:1): Gtk-WARNING **: Locale not supported by C library.
        Using the fallback 'C' locale.
process 1: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/etc/machine-id": No such file or directory

Any ideas on how to enhance performance of the container and to avoid the errors?

Cheers
Tset

Tset-Noitamotua commented Dec 21, 2016

@qinwf Thanks for Windows 10 hint. It worked for me, too. But I did it a bit different:

  1. choco install xming
  2. put Xming.exe on PATH
  3. Xming.exe :0 -multiwindow -clipboard -ac -from 192.168.178.21 (network IP of my host)
  4. docker run -e DISPLAY=192.168.178.21:0 jess/firefox

It's a bit laggy but works. so cool! Though some errors appear in the console

(firefox:1): Gtk-WARNING **: Locale not supported by C library.
        Using the fallback 'C' locale.
process 1: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/etc/machine-id": No such file or directory

Any ideas on how to enhance performance of the container and to avoid the errors?

Cheers
Tset

@marcelmfs

This comment has been minimized.

Show comment
Hide comment
@marcelmfs

marcelmfs Jan 11, 2017

@ikabar-tracxpoint you probably have something else allocating the network port, use:
lsof -i TCP:6000 to figure out which process is holding the socket, and if you'd like to, kill the PID.

marcelmfs commented Jan 11, 2017

@ikabar-tracxpoint you probably have something else allocating the network port, use:
lsof -i TCP:6000 to figure out which process is holding the socket, and if you'd like to, kill the PID.

@ikabar-tracxpoint

This comment has been minimized.

Show comment
Hide comment
@ikabar-tracxpoint

ikabar-tracxpoint Jan 23, 2017

Hi @marcelmfs.

If I run XQuartz than I have:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
X11.bin 20702 ikabar 11u IPv6 0x84a809611258619d 0t0 TCP *:6000 (LISTEN)
X11.bin 20702 ikabar 12u IPv4 0x84a809611cf250a5 0t0 TCP *:6000 (LISTEN)

If I kill XQuartz I have nothing.

ikabar-tracxpoint commented Jan 23, 2017

Hi @marcelmfs.

If I run XQuartz than I have:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
X11.bin 20702 ikabar 11u IPv6 0x84a809611258619d 0t0 TCP *:6000 (LISTEN)
X11.bin 20702 ikabar 12u IPv4 0x84a809611cf250a5 0t0 TCP *:6000 (LISTEN)

If I kill XQuartz I have nothing.

@steve-heslouin

This comment has been minimized.

Show comment
Hide comment
@steve-heslouin

steve-heslouin Feb 21, 2017

@ikabar-tracxpoint I had the same problem as you and i made it work as follow:

Close xQuartz.

IN a normal terminal, run as follow:

socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"

You can put it in a screen session
Still in a normal terminal, enter:

docker run -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=<PUT YOUR IP HERE>:0 jess/firefox
It take time to boot xquartx, and voila, it should work fine

Good luck

steve-heslouin commented Feb 21, 2017

@ikabar-tracxpoint I had the same problem as you and i made it work as follow:

Close xQuartz.

IN a normal terminal, run as follow:

socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"

You can put it in a screen session
Still in a normal terminal, enter:

docker run -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=<PUT YOUR IP HERE>:0 jess/firefox
It take time to boot xquartx, and voila, it should work fine

Good luck

@ikabar-tracxpoint

This comment has been minimized.

Show comment
Hide comment
@ikabar-tracxpoint

ikabar-tracxpoint Feb 23, 2017

@steve-heslouin I need to buy you a beer!

Well, I did manage based on other similar answers to get jess/firefox running but had a problem with my container.

But following your comment I started digging more and found that the root cause for me was using the latest version of XQuartz. (This is a mac issue).
When downgrading to XQuartz 2.7.8 things started to work.

ikabar-tracxpoint commented Feb 23, 2017

@steve-heslouin I need to buy you a beer!

Well, I did manage based on other similar answers to get jess/firefox running but had a problem with my container.

But following your comment I started digging more and found that the root cause for me was using the latest version of XQuartz. (This is a mac issue).
When downgrading to XQuartz 2.7.8 things started to work.

@steve-heslouin

This comment has been minimized.

Show comment
Hide comment
@steve-heslouin

steve-heslouin Feb 23, 2017

@ikabar-tracxpoint
Anytime for the beer, i accept delivery :P

Regarding XQuartz, I'm running 2.7.11 (latest version) on latest release of Sierra and so far so good

steve-heslouin commented Feb 23, 2017

@ikabar-tracxpoint
Anytime for the beer, i accept delivery :P

Regarding XQuartz, I'm running 2.7.11 (latest version) on latest release of Sierra and so far so good

@lukaslueg

This comment has been minimized.

Show comment
Hide comment
@lukaslueg

lukaslueg Mar 25, 2017

I've got a Dockerfile in my dotfiles that gives me a blank throwaway box with all my beloved shell settings. On MacOS, I have the following shell-function that (re-) builds the image, starts socat to pass X11 to quartz (think firefox), starts a new shell, and throws everything away (including socat) when I quit.

boxxed_quartz() {
    docker build -t fedora_boxxed:latest - < $HOME/.dotfiles/fedora_boxxed
    socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\" & SOCAT_PID=$!
    docker run -w /root -v $HOME/.dotfiles:/root/.dotfiles:ro -e TERM=$TERM -e DISPLAY=$(ifconfig vboxnet0 | grep "inet" | cut -d " " -f 2):0 --rm=true -it fedora_boxxed
    kill $SOCAT_PID
}

lukaslueg commented Mar 25, 2017

I've got a Dockerfile in my dotfiles that gives me a blank throwaway box with all my beloved shell settings. On MacOS, I have the following shell-function that (re-) builds the image, starts socat to pass X11 to quartz (think firefox), starts a new shell, and throws everything away (including socat) when I quit.

boxxed_quartz() {
    docker build -t fedora_boxxed:latest - < $HOME/.dotfiles/fedora_boxxed
    socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\" & SOCAT_PID=$!
    docker run -w /root -v $HOME/.dotfiles:/root/.dotfiles:ro -e TERM=$TERM -e DISPLAY=$(ifconfig vboxnet0 | grep "inet" | cut -d " " -f 2):0 --rm=true -it fedora_boxxed
    kill $SOCAT_PID
}
@Integralist

This comment has been minimized.

Show comment
Hide comment
@Integralist

Integralist Apr 12, 2017

I'm having issues with this.
I'm trying to get to a point where I can yank something from Vim (inside the container).
And have the yanked text end up on both the linux clipboard and the host (macOS) clipboard.

I have the following Makefile which copies my vim directory and vimrc into the docker build context, then builds an image with vim installed and then runs the container (it fires up xquarts and socat before it runs):

copy_vim_files:
	@if [ ! -d "./.vim" ]; then cp -r "$$HOME/.vim" ./.vim; fi
	@if [ ! -f "./.vimrc" ]; then cp "$$HOME/.vimrc" ./.vimrc; fi

remove_vim_files:
	@rm -rf ./.vim
	@rm ./.vimrc

xquart:
	@if [[ $(shell ls /Applications/Utilities/ | grep -c XQuartz) -lt 1 ]]; then echo Installing XQuartz && brew install Caskroom/cask/xquartz; else echo XQuartz already installed; fi
	@if [[ $(shell echo $(shell ps aux | grep -ic '/Applications/Utilities/XQuartz.app')) -lt 3 ]]; then echo Opening XQuartz && open -a XQuartz; else echo XQuartz is already running; fi

socat:
	@if [[ $(shell echo $(shell brew list | grep -ic socat)) -lt 1 ]]; then echo Installing Socat && brew install socat; else echo Socat already installed; fi
	@if [[ $(shell echo $(shell ps aux | grep -ic socat)) -lt 4 ]]; then echo "Opening Socat as a background process" && (socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$$DISPLAY\" &); else echo Socat is already running; fi
	@echo "Don't forget to kill the socat process when you're done!" # TODO: try storing process id with $!

build: copy_vim_files
	@docker build -t python-container-with-vim .

run: xquart socat build
	$(eval IP := $(shell ifconfig vboxnet0 | grep "inet" | cut -d " " -f 2))
	@docker run -it --rm=true -e TERM=$$TERM -e DISPLAY=$(IP):0 -v "$$(pwd)":/app -v /tmp/.X11-unix:/tmp/.X11-unix python-container-with-vim /bin/bash

clean: remove_vim_files
	-@docker rmi -f python-container-with-vim &> /dev/null || true

rebuild: clean run

Here's my Dockerfile:

FROM python:3.6.1

WORKDIR /tmp

RUN apt-get update -y
RUN apt-get install -y git xclip
RUN git clone https://github.com/vim/vim.git && cd vim && ./configure && apt install ncurses-dev && make && make install

ADD ./requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt

COPY .vim /root/.vim
COPY .vimrc /root/.vimrc

WORKDIR /app

Note: my .vimrc is setup to use set clipboard+=unnamed

But when I run the container and try to check that xclip works, I get an error:

xclip -selection clipboard < app.py
2017/04/12 10:26:11 socat[61346] E connect(5, LEN=2 AF=1 "<anon>", 2): Invalid argument Error: Can't open display: 10.51.50.1:0

Does anyone know how I can fix that error, and then beyond that how to get the linux clipboard contents onto my host clipboard?

Integralist commented Apr 12, 2017

I'm having issues with this.
I'm trying to get to a point where I can yank something from Vim (inside the container).
And have the yanked text end up on both the linux clipboard and the host (macOS) clipboard.

I have the following Makefile which copies my vim directory and vimrc into the docker build context, then builds an image with vim installed and then runs the container (it fires up xquarts and socat before it runs):

copy_vim_files:
	@if [ ! -d "./.vim" ]; then cp -r "$$HOME/.vim" ./.vim; fi
	@if [ ! -f "./.vimrc" ]; then cp "$$HOME/.vimrc" ./.vimrc; fi

remove_vim_files:
	@rm -rf ./.vim
	@rm ./.vimrc

xquart:
	@if [[ $(shell ls /Applications/Utilities/ | grep -c XQuartz) -lt 1 ]]; then echo Installing XQuartz && brew install Caskroom/cask/xquartz; else echo XQuartz already installed; fi
	@if [[ $(shell echo $(shell ps aux | grep -ic '/Applications/Utilities/XQuartz.app')) -lt 3 ]]; then echo Opening XQuartz && open -a XQuartz; else echo XQuartz is already running; fi

socat:
	@if [[ $(shell echo $(shell brew list | grep -ic socat)) -lt 1 ]]; then echo Installing Socat && brew install socat; else echo Socat already installed; fi
	@if [[ $(shell echo $(shell ps aux | grep -ic socat)) -lt 4 ]]; then echo "Opening Socat as a background process" && (socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$$DISPLAY\" &); else echo Socat is already running; fi
	@echo "Don't forget to kill the socat process when you're done!" # TODO: try storing process id with $!

build: copy_vim_files
	@docker build -t python-container-with-vim .

run: xquart socat build
	$(eval IP := $(shell ifconfig vboxnet0 | grep "inet" | cut -d " " -f 2))
	@docker run -it --rm=true -e TERM=$$TERM -e DISPLAY=$(IP):0 -v "$$(pwd)":/app -v /tmp/.X11-unix:/tmp/.X11-unix python-container-with-vim /bin/bash

clean: remove_vim_files
	-@docker rmi -f python-container-with-vim &> /dev/null || true

rebuild: clean run

Here's my Dockerfile:

FROM python:3.6.1

WORKDIR /tmp

RUN apt-get update -y
RUN apt-get install -y git xclip
RUN git clone https://github.com/vim/vim.git && cd vim && ./configure && apt install ncurses-dev && make && make install

ADD ./requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt

COPY .vim /root/.vim
COPY .vimrc /root/.vimrc

WORKDIR /app

Note: my .vimrc is setup to use set clipboard+=unnamed

But when I run the container and try to check that xclip works, I get an error:

xclip -selection clipboard < app.py
2017/04/12 10:26:11 socat[61346] E connect(5, LEN=2 AF=1 "<anon>", 2): Invalid argument Error: Can't open display: 10.51.50.1:0

Does anyone know how I can fix that error, and then beyond that how to get the linux clipboard contents onto my host clipboard?

@dragon788

This comment has been minimized.

Show comment
Hide comment
@dragon788

dragon788 Apr 29, 2017

Contributor

@Integralist Completely theoretical untested possibly unhinged theory, but does running a docker exec <container> <command> in a subshell outside the container and piping the result of the subshell over to pbcopy on OSX work?

So assuming you've "yanked" inside the vim window in the container, then calling the command $(docker exec myvimcontainer xclip -o) should write to stdout, so if you add | pbcopy it should end up in your OSX clipboard?

$(docker exec myvimcontainer xclip -o) | pbcopy

You could also try specifying a different display to xclip though I'm not sure it will "see" across the connection from the container to the host.

Contributor

dragon788 commented Apr 29, 2017

@Integralist Completely theoretical untested possibly unhinged theory, but does running a docker exec <container> <command> in a subshell outside the container and piping the result of the subshell over to pbcopy on OSX work?

So assuming you've "yanked" inside the vim window in the container, then calling the command $(docker exec myvimcontainer xclip -o) should write to stdout, so if you add | pbcopy it should end up in your OSX clipboard?

$(docker exec myvimcontainer xclip -o) | pbcopy

You could also try specifying a different display to xclip though I'm not sure it will "see" across the connection from the container to the host.

@ksylvan

This comment has been minimized.

Show comment
Hide comment
@ksylvan

ksylvan Jul 14, 2017

This discussion was SUPER useful! After brew cask install xquartz and starting XQuartz:

In the xterm shell, I do this:

$ docker -v
Docker version 17.06.0-ce, build 02c1d87
$ socat TCP-LISTEN:6001,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\" &
[1] 55121
$ docker run -d --rm -e HOME=$(pwd) -e XAUTHORITY=/tmp/xauth \
  -v ~/.Xauthority:/tmp/xauth \
  -e DISPLAY=$(ifconfig en4 | grep 'inet '|awk '{print $2}'):1 \
  --net host -v $(pwd):$(pwd) kayvan/scidvspc

And I have the scidvspc GUI working perfectly. Thank you all!

ksylvan commented Jul 14, 2017

This discussion was SUPER useful! After brew cask install xquartz and starting XQuartz:

In the xterm shell, I do this:

$ docker -v
Docker version 17.06.0-ce, build 02c1d87
$ socat TCP-LISTEN:6001,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\" &
[1] 55121
$ docker run -d --rm -e HOME=$(pwd) -e XAUTHORITY=/tmp/xauth \
  -v ~/.Xauthority:/tmp/xauth \
  -e DISPLAY=$(ifconfig en4 | grep 'inet '|awk '{print $2}'):1 \
  --net host -v $(pwd):$(pwd) kayvan/scidvspc

And I have the scidvspc GUI working perfectly. Thank you all!

@kbroughton

This comment has been minimized.

Show comment
Hide comment
@kbroughton

kbroughton Oct 19, 2017

The magic for me was the above, swap en4 for en13. ifconfig and try one of the ones that thas 'inet ' that is a space, not a number. Then i changed :1 to :0 and voila!

docker run -it -e HOME=$(pwd) -e XAUTHORITY=/tmp/xauth -v 
/Users/kbroughton/.Xauthority:/tmp/xauth -e DISPLAY=$(ifconfig en13 | grep 'inet '|awk '{print 
$2}'):0 --net host -v $(pwd):$(pwd) 3a29 bash

kbroughton commented Oct 19, 2017

The magic for me was the above, swap en4 for en13. ifconfig and try one of the ones that thas 'inet ' that is a space, not a number. Then i changed :1 to :0 and voila!

docker run -it -e HOME=$(pwd) -e XAUTHORITY=/tmp/xauth -v 
/Users/kbroughton/.Xauthority:/tmp/xauth -e DISPLAY=$(ifconfig en13 | grep 'inet '|awk '{print 
$2}'):0 --net host -v $(pwd):$(pwd) 3a29 bash
@thom-nic

This comment has been minimized.

Show comment
Hide comment
@thom-nic

thom-nic Feb 5, 2018

I've found using xhost is the easiest way to do this, as long as mounting the unix socket from MacOS is a no-go. It was mentioned above but I wanted to give a more complete example.

First, run XQuartz and open the pref pane. On the Security tab, make sure Allow connections from network clients is enabled. If it was not already checked, you probably need to quit and restart XQuartz.

Now from a mac terminal, run:

open -a XQuartz
xhost + $(hostname)      # this must be called after starting xquartz

docker run --rm -it -e DISPLAY=$(hostname):0 openmicroscopy/octave \
    --eval "graphics_toolkit gnuplot;plot(rand(10));pause"   # this is just an example to show X11 working

If the above doesn't work, try this instead:

IFACE=en4       # change this to whatever your active interface is
IP=$(ifconfig $IFACE | grep inet | awk '$1=="inet" {print $2}')
xhost + $IP       # The '+' is important!

# now run docker as above, substitute `-e DISPLAY=$IP:0`

thom-nic commented Feb 5, 2018

I've found using xhost is the easiest way to do this, as long as mounting the unix socket from MacOS is a no-go. It was mentioned above but I wanted to give a more complete example.

First, run XQuartz and open the pref pane. On the Security tab, make sure Allow connections from network clients is enabled. If it was not already checked, you probably need to quit and restart XQuartz.

Now from a mac terminal, run:

open -a XQuartz
xhost + $(hostname)      # this must be called after starting xquartz

docker run --rm -it -e DISPLAY=$(hostname):0 openmicroscopy/octave \
    --eval "graphics_toolkit gnuplot;plot(rand(10));pause"   # this is just an example to show X11 working

If the above doesn't work, try this instead:

IFACE=en4       # change this to whatever your active interface is
IP=$(ifconfig $IFACE | grep inet | awk '$1=="inet" {print $2}')
xhost + $IP       # The '+' is important!

# now run docker as above, substitute `-e DISPLAY=$IP:0`
@jay-hankins

This comment has been minimized.

Show comment
Hide comment
@jay-hankins

jay-hankins Feb 15, 2018

Note that, if you have trouble finding the correct IP, docker.for.mac.host.internal is routable from the container networks, so setting it as the DISPLAY variable inside the container works without trying to track down the appropriate interface's IP.

jay-hankins commented Feb 15, 2018

Note that, if you have trouble finding the correct IP, docker.for.mac.host.internal is routable from the container networks, so setting it as the DISPLAY variable inside the container works without trying to track down the appropriate interface's IP.

@thom-nic

This comment has been minimized.

Show comment
Hide comment
@thom-nic

thom-nic Feb 16, 2018

@jay-hankins I tried both DISPLAY=tcp:docker.for.mac.host.internal:0 and DISPLAY=192.168.65.2:0. I suspect the problem lies in what do you use for xhost + $IP on the MacOS side? I tried xhost + 192.168.65.2 but that did not work, I can't open a display from inside the container unless I use the public hostname or IP.

thom-nic commented Feb 16, 2018

@jay-hankins I tried both DISPLAY=tcp:docker.for.mac.host.internal:0 and DISPLAY=192.168.65.2:0. I suspect the problem lies in what do you use for xhost + $IP on the MacOS side? I tried xhost + 192.168.65.2 but that did not work, I can't open a display from inside the container unless I use the public hostname or IP.

@jay-hankins

This comment has been minimized.

Show comment
Hide comment
@jay-hankins

jay-hankins Feb 16, 2018

@thom-nic Sorry, should have clarified; I use the socat method, not the xhost method. I tried a few different things but xhost never seemed to work.

So, here's what works for me on mac OS High Sierra 10.13.3:

$ socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\" & 
$ docker run -e DISPLAY=docker.for.mac.host.internal:0 jess/tor-browser

image

As I said, docker.for.mac.host.internal is only known to the client containers, so something like xhost +$(docker.for.mac.host.internal) wouldn't work.

jay-hankins commented Feb 16, 2018

@thom-nic Sorry, should have clarified; I use the socat method, not the xhost method. I tried a few different things but xhost never seemed to work.

So, here's what works for me on mac OS High Sierra 10.13.3:

$ socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\" & 
$ docker run -e DISPLAY=docker.for.mac.host.internal:0 jess/tor-browser

image

As I said, docker.for.mac.host.internal is only known to the client containers, so something like xhost +$(docker.for.mac.host.internal) wouldn't work.

@tateman74

This comment has been minimized.

Show comment
Hide comment
@tateman74

tateman74 Apr 23, 2018

Hey Guys,

Is there still momentum on this? I realize this thread is nearly 4 years old. But, I can also see extremely valid use cases of serving UIs from containers as does everyone else here.

I'm doing all of the above with Docker 18.0.3, a recent socat version, XQuartz 2.7.11 and OSX 10.13.3.

I've tried @jessfraz's chrome, firefox, slack, etc, etc and all of them are basically unusable.

Piergiorgio Niero's demo of getting GPU support into the container is a pretty cool read:
https://medium.com/@pigiuz/hw-accelerated-gui-apps-on-docker-7fd424fe813e

Seems to get GLXGears going much faster on the GL side. It's obviously super impressive that he's running Blender in a container. I'm guessing I'm not going to be getting a fantastic render of Gangnam Style Doom - (credit Playcanvas guys - you're AWESOME):
https://playcanv.as/b/abx8Go4g/

Am I just an idiot? Don't answer that! 😀
Is anyone seeing near perfect performance from say Firefox or Chrome in containers streaming through X11?

Should I try the xhost route instead? Are we seeing similar results on Windows with Windows containers?

Thanks for any advice.

Steven

tateman74 commented Apr 23, 2018

Hey Guys,

Is there still momentum on this? I realize this thread is nearly 4 years old. But, I can also see extremely valid use cases of serving UIs from containers as does everyone else here.

I'm doing all of the above with Docker 18.0.3, a recent socat version, XQuartz 2.7.11 and OSX 10.13.3.

I've tried @jessfraz's chrome, firefox, slack, etc, etc and all of them are basically unusable.

Piergiorgio Niero's demo of getting GPU support into the container is a pretty cool read:
https://medium.com/@pigiuz/hw-accelerated-gui-apps-on-docker-7fd424fe813e

Seems to get GLXGears going much faster on the GL side. It's obviously super impressive that he's running Blender in a container. I'm guessing I'm not going to be getting a fantastic render of Gangnam Style Doom - (credit Playcanvas guys - you're AWESOME):
https://playcanv.as/b/abx8Go4g/

Am I just an idiot? Don't answer that! 😀
Is anyone seeing near perfect performance from say Firefox or Chrome in containers streaming through X11?

Should I try the xhost route instead? Are we seeing similar results on Windows with Windows containers?

Thanks for any advice.

Steven

@galderz

This comment has been minimized.

Show comment
Hide comment
@galderz

galderz Apr 26, 2018

I've tried @jessfraz's chrome, firefox, slack, etc, etc and all of them are basically unusable.

I've tried slack but it's way too slow for me too :(

galderz commented Apr 26, 2018

I've tried @jessfraz's chrome, firefox, slack, etc, etc and all of them are basically unusable.

I've tried slack but it's way too slow for me too :(

@tateman74

This comment has been minimized.

Show comment
Hide comment
@tateman74

tateman74 Apr 26, 2018

Too bad. I see alot of use cases to be able to run GUIs in containers. Odd to think of how something could be slow that is streaming from one place to another on the same computer. Would that be an X11 problem or a Docker problem? Has anyone tried VNC on local from container to host? Obviously, it would have lag if those were apart. But, does it if they're on the same box?

Steven

tateman74 commented Apr 26, 2018

Too bad. I see alot of use cases to be able to run GUIs in containers. Odd to think of how something could be slow that is streaming from one place to another on the same computer. Would that be an X11 problem or a Docker problem? Has anyone tried VNC on local from container to host? Obviously, it would have lag if those were apart. But, does it if they're on the same box?

Steven

@galderz

This comment has been minimized.

Show comment
Hide comment
@galderz

galderz Apr 27, 2018

I've tried the socat method and that's way too slow. I'm yet to try xhost

galderz commented Apr 27, 2018

I've tried the socat method and that's way too slow. I'm yet to try xhost

@rocwenlinux

This comment has been minimized.

Show comment
Hide comment
@rocwenlinux

rocwenlinux Jun 4, 2018

Great!
Now i can use PAC manager in macos

docker run -it -e DISPLAY=docker.for.mac.localhost:0 -v /tmp/.X11-unix:/tmp/.X11-unix --rm dresantos/pac pac

rocwenlinux commented Jun 4, 2018

Great!
Now i can use PAC manager in macos

docker run -it -e DISPLAY=docker.for.mac.localhost:0 -v /tmp/.X11-unix:/tmp/.X11-unix --rm dresantos/pac pac

@tateman74

This comment has been minimized.

Show comment
Hide comment
@tateman74

tateman74 Jun 4, 2018

@rocwenlinux - can you let us know how performance goes there? Everyone else is experiencing dial like performance when mirroring X11 everywhere else.

tateman74 commented Jun 4, 2018

@rocwenlinux - can you let us know how performance goes there? Everyone else is experiencing dial like performance when mirroring X11 everywhere else.

@rocwenlinux

This comment has been minimized.

Show comment
Hide comment
@rocwenlinux

rocwenlinux Jun 4, 2018

@tateman74
I just create an ssh connection in PAC manager and use it, it is very fast, no performance issue.

I just follow the steps summarised by saulshanabrook, the only change is host ip address because of macos. i use docker.for.mac.localhost

brew install socat
brew cask install xquartz
open -a XQuartz

socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:"$DISPLAY"

in another window

docker run -it -e DISPLAY=docker.for.mac.localhost:0 -v /tmp/.X11-unix:/tmp/.X11-unix --rm dresantos/pac pac

My macbook info:
macOS 10.13.4 High Sierra
docker is installed from Docker.dmg
cpu i7

rocwenlinux commented Jun 4, 2018

@tateman74
I just create an ssh connection in PAC manager and use it, it is very fast, no performance issue.

I just follow the steps summarised by saulshanabrook, the only change is host ip address because of macos. i use docker.for.mac.localhost

brew install socat
brew cask install xquartz
open -a XQuartz

socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:"$DISPLAY"

in another window

docker run -it -e DISPLAY=docker.for.mac.localhost:0 -v /tmp/.X11-unix:/tmp/.X11-unix --rm dresantos/pac pac

My macbook info:
macOS 10.13.4 High Sierra
docker is installed from Docker.dmg
cpu i7

@tateman74

This comment has been minimized.

Show comment
Hide comment
@tateman74

tateman74 Jun 4, 2018

Oh I see. You're just mirroring a terminal then? No real GUI applications which is kind of what the thread is all about right?

tateman74 commented Jun 4, 2018

Oh I see. You're just mirroring a terminal then? No real GUI applications which is kind of what the thread is all about right?

@rocwenlinux

This comment has been minimized.

Show comment
Hide comment
@rocwenlinux

rocwenlinux Jun 4, 2018

Probably. I am not sure how PAC implement the GUI (perl+GTK?), but its main function is to provide ssh terminal and manage ssh connections, not complex. It isn't a heavy-GUI application.

rocwenlinux commented Jun 4, 2018

Probably. I am not sure how PAC implement the GUI (perl+GTK?), but its main function is to provide ssh terminal and manage ssh connections, not complex. It isn't a heavy-GUI application.

@titosemi

This comment has been minimized.

Show comment
Hide comment
@titosemi

titosemi Jun 22, 2018

I also gave this a try with the X11 socket approach and it is way too slow. Mostly unusable 😞

titosemi commented Jun 22, 2018

I also gave this a try with the X11 socket approach and it is way too slow. Mostly unusable 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment