The program received an X Window System error

Sometimes when launching a graphical application from a container, I get the following error:

Gdk-ERROR **: The program 'nemo' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadAccess (attempt to access private resource denied)'.
  (Details: serial 184 error_code 10 request_code 130 (MIT-SHM) minor_code 1)

This happens irregularly and with more than 1 program.

The error may appear several times if you try to restart the application after this error, or it may not appear at all.

My setup:

  • Host: Linux Mint 20
  • Container: Linux Mint 20
  • LXD version: 4.11

The container uses a profile with the following configuration for GUI apps:

  environment.DISPLAY: :0
    bind: container
    connect: unix:@/tmp/.X11-unix/X0
    listen: unix:@/tmp/.X11-unix/X0
    security.gid: "1000"
    security.uid: "1000"
    type: proxy
    type: gpu