I am running lxc2.0 container(privileged) on Ubuntu 16.0.4LTS 32-bit.

Inside the container I installed mesa-utils that has the glxgears app.

my container config file /var/lib/lxc/mk7i_container/config is:

 Template used to create this container: /usr/share/lxc/templates/lxc-download
# Parameters passed to the template: --no-validate
# For additional config options, please look at lxc.container.conf(5)

# Uncomment the following line to support nesting containers:
#lxc.include = /usr/share/lxc/config/nesting.conf
# (Be aware this has security implications)

# Distribution configuration
lxc.include = /usr/share/lxc/config/ubuntu.common.conf
lxc.arch = x86

lxc.cgroup.devices.allow = c 1:1 rwm

lxc.cgroup.devices.allow = c 130:* rwm
lxc.cgroup.devices.allow = c 124:* rwm
lxc.cgroup.devices.allow = c 122:* rwm
lxc.cgroup.devices.allow = c 123:* rwm
lxc.cgroup.devices.allow = c 126:* rwm
lxc.cgroup.devices.allow = c 127:0 rwm
lxc.cgroup.devices.allow = c 120:0 rwm

# Container specific configuration
lxc.rootfs = /var/lib/lxc/mk7i_container/rootfs
lxc.rootfs.backend = dir
lxc.utsname = mk7i_container

# Network configuration
lxc.network.type = veth
lxc.network.link = lxcbr0
lxc.network.flags = up
lxc.network.hwaddr = 00:16:3e:c8:fd:1e

#mounts for XServer DISPLAY
lxc.mount.entry = /dev/dri dev/dri none bind,optional,create=dir
lxc.mount.entry = /tmp/.X11-unix tmp/.X11-unix none bind,optional,create=dir
lxc.mount.entry = /dev/video0 dev/video0 none bind,optional,create=file

To log in into the container as user 'Ubuntu', I am using the following command:

sudo lxc-console -n mk7i_container

After login, I set the DISPLAY env variable as:

export DISPLAY=":0.0"

And run glxgears and it runs fine. I can see the Xwindow with gears moving in it.

However, after that I enter root mode via sudo su command. And try to run glxgears, but I get the following error:

No protocol specified
Error: couldn't open display :0.0

Not sure why this error is coming. If user ubuntu runs x apps fine , I expected root to do the same.

Anyone know what's wrong here ?

  • Is this related to x-forwarding? Like logging into a server remotely? If so, could you please take a look at my question here and see if your answer could partially or completely answer my question? – Amir Apr 26 '18 at 0:25

I was able to fix it and run glxgears in root mode. The problem was with the xauth.

The host system already had xauth.The idea is to use the key of the already trusted user, which in my case was manik on the host system.

Using command xauth list gave me the following output:

manik/unix:0  MIT-MAGIC-COOKIE-1  a4f6256398303725763c5595f404afbb

I am going to use the key in hex(right most entry above) in my root user account inside container.

I installed xauth package in the container:

sudo apt-get install xauth

Inside root user prompt in container:

export DISPLAY=":0"
xauth add $DISPLAY . a4f6256398303725763c5595f404afbb

And now glxgears works fine in root mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.