Connecting chrome in container to x11 server on host Windows 10 host

I have tried several examples and images for using Chrome in a container with x11 to the host for GUI. I never could get one to work so I finally started from scratch with FROM centos. On my work laptop, I was able to get Chrome working on the container and use vXsrv on my Windows 10 laptop to use Chrome in the container. I used jess/chrome as a sample and built my own with the hints there - even though I never could get her ubuntu image to work for me.

At home, I tried the very same set up as at work except no proxy at home. At home I cannot connect to the x server. I can test the x server with xcalc and xclock (included with vXsrv) and those both work. But I can’t connect from my container to the vXsrv server on my host.

On the container, I have tried:

export DISPLAY=

or used the same address in the command line for chrome:

google-chrome-stable --no-sandbox --display=

In either case, this is the error returned at home (but it works at work)

Gtk-WARNING **: cannot open display:

Any suggestions? I’m supposed to present this to our docker user group in a week! I’m desparate.

Thanks in advance.

Edit to add: I can ping from the container so the container can see the host.

It sounds like you may just need to run ‘xhost +’ on your host machine.

1 Like

Thanks, James. I’ll try that when I get home tonight.

Another thing I’ll try I found at work today. When I created my image originally, I tested and connected to the x server on This morning, I recreated the image, started the X server again, and couldn’t connect to the X server so I tried setting DISPLAY to point to the HNS Internal NIC IP address instead and that got my work instance going again. I’ll try using the HNS Internal NIC at home, too. I’m not sure how the X Server chooses which NIC it binds to but it appears to be inconsistent.

As a reminder, this allows anybody who can connect to your X server unlimited access to show things on your display and monitor things that are going on like mouse movements and keystrokes.

Combining a setup where you’re allowing keyloggers to be trivially installed with one where you need to be root to do basic things seems like a poor setup security-wise. It’d probably be much easier and safer to just install Chrome on the host desktop.

1 Like

Very true. Since he is working on a self-contained system (everything is running locally), a simple act like disconnecting the network before running ‘xhost +’ could give him some protection during testing (all he really needs to know that it works is for the Chrome window to come up). Of course, if he is sure what IP address he needs to give permission to he could use that with the xhost command.

Dalepres, check this out for more info on the xhost command:

1 Like

I got it to work. There are a lot of little details to work out: I get some errors in the console when opening Chrome, home page causes Chrome to crash but other pages all work. This isn’t just; some pages crash and some work. Just want to share this for others who are looking for the same issues.

The solution was the IP address for the display parameter. I discovered this at work today. Last week, I was able to connect to my VcXsrv X server using Today that didn’t work so I figured out it would connect to the Hyper-v HNS NIC. It turns out that VcXsrv is unpredictable about to which IP/NIC it binds. So, sure enough, I got home and tested it and, at home, it was connected to my laptop’s primary WIFI instead of the Docker or Hyper-v virtual NICs. So, hint to future people struggling with this: try every IPV4 address you find using ipconfig on Windows as your display address.

I do find posts from others who solved similar problems with xauth and xhost. My solution is just one of many possibilities; something to try.

Thanks to those who gave suggestions and help.

i wonder if using “host.docker.internal” would have worked for you.
i am curious what the final config was. good read though.

in ubuntu i did this inside the container:

install a test app, like a dclock , which is " Digital clock for the X Window System with flexible display"

apt-get install dclock

then set the environment variable:

export DISPLAY=host.docker.internal.0.0

then run the test app


on my windows 10 box i have an Xserver running (moba Xterm).

i tried again with chromium

apt-get install -y chromium-browser

then run the browser

root@a14924c65eef:/# chromium-browser
[5155:5155:0907/] Running as root without --no-sandbox is not supported. See

but then this way worked (no crashed pages), but this was in the docker cmd console:

root@a14924c65eef:/# chromium-browser  --no-sandbox
[5704:5714:0907/] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[5733:5733:0907/] InitializeSandbox() called with multiple threads in process gpu-process.
[5704:5918:0907/] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[5704:5704:0907/] Lost UI shared context.
[5921:5929:0907/] ContextResult::kFatalFailure: Shared memory handle is not valid
[5704:6324:0907/] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[5704:6324:0907/] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[5704:6324:0907/] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[5704:6324:0907/] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[5704:6324:0907/] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory

root@a14924c65eef:/# chromium-browser  --no-sandbox