When using `incus exec -- ls /run/user/1000` non of the sockets are linked in?

This is really a follow-up to this post /run/user/uid missing when using `incus exec container -- sudo --user uname --login`

  • When I login (incus exec qt-apps -- login) everything works perfectly.
  • When I start the container and try to list /run/user folder, it shows as empty.
  • I can now manually create the /run/user/1000 folder by systemctl start user@1000
  • However, none of devices or X11 display get linked in
  • Note the devices are mounted but not linked in…
  • How can I kick-start the proxy’s etc?

After start

❯ incus exec qt-apps -- sudo --user user1 ls -Al /run/user /tmp/.X11-unix
/run/user:
total 0

/tmp/.X11-unix:
total 0
❯ incus exec qt-apps -- sudo --login --user user1 ls -Al /mnt/.container_sockets          
total 0
srwxrwxrwx 1 root   root   0 Jul 15 12:08 X0
srw-rw-rw- 1 houman houman 0 Jul 15 12:08 native
srw-rw-rw- 1 houman houman 0 Jul 15 12:08 pipewire-0
srw-rw-rw- 1 houman houman 0 Jul 15 12:08 pipewire-0-manager

Starting user@1000

  • Then if I kickstart user@1000, I can actually see the folder (/run/user/1000)
  • Although the 1000 folder is there non of the devices are getting linked
  • Furthermore, X0 link is also missing
  • In case it helps, I have attached the associate journalctl logs from container to the bottom of the post
❯ incus exec qt-apps -- sudo --user user1 sudo systemctl start user@1000;

❯ incus exec qt-apps -- sudo --login --user user1 ls -Al /run/user/1000 /tmp/.X11-unix    
/run/user/1000:
total 0
srw-rw-rw- 1 user1 user1   0 Jul 15 23:04 bus
drwx------ 2 user1 user1 160 Jul 15 23:04 gnupg
drwxr-xr-x 2 user1 user1  60 Jul 15 23:04 p11-kit
drwxr-xr-x 6 user1 user1 160 Jul 15 23:04 systemd

/tmp/.X11-unix:
total 0

Container config

❯ incus config show qt-apps -e                                                             
architecture: x86_64
config:
  environment.DISPLAY: :0
  image.architecture: x86_64
  image.description: Archlinux  x86_64 (20250629_04:18)
  image.name: archlinux--x86_64-default-20250629_04:18
  image.os: archlinux
  image.serial: "20250629_04:18"
  image.variant: default
  nvidia.runtime: "true"
  volatile.base_image: f962ccb96cdb24b78c04ba9b28d396712af3154d8ca31b616931192b0d27ec43
  volatile.cloud-init.instance-id: 149f9edf-63bb-406d-b72f-3191a9bbe71a
  volatile.eth0.host_name: veth4fc3579f
  volatile.eth0.hwaddr: 10:66:6a:ba:e2:09
  volatile.eth0.name: eth0
  volatile.idmap.base: "0"
  volatile.idmap.current: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.last_state.idmap: '[]'
  volatile.last_state.power: RUNNING
  volatile.last_state.ready: "false"
  volatile.uuid: b0c9924d-16bd-4750-b8a5-3b26d6378e30
  volatile.uuid.generation: b0c9924d-16bd-4750-b8a5-3b26d6378e30
devices:
  eth0:
    network: incusbr0
    type: nic
  mygpu:
    gid: "985"
    gputype: physical
    type: gpu
  pipewire_manager_socket:
    path: /mnt/.container_sockets/pipewire-0-manager
    shift: "true"
    source: /run/user/1000/pipewire-0-manager
    type: disk
  pipewire_socket:
    path: /mnt/.container_sockets/pipewire-0
    shift: "true"
    source: /run/user/1000/pipewire-0
    type: disk
  pulseaudio_socket:
    path: /mnt/.container_sockets/native
    shift: "true"
    source: /run/user/1000/pulse/native
    type: disk
  root:
    path: /
    pool: incus_storage
    type: disk
  x_socket:
    path: /mnt/.container_sockets/X0
    shift: "true"
    source: /tmp/.X11-unix/X0
    type: disk
ephemeral: false
profiles:
- audio-video-support
stateful: false
description: ""

Journalctl log regarding user@1000

Jul 15 23:10:02 qt-apps sudo[209]:   user1 : TTY=pts/2 ; PWD=/home/user1 ; USER=root ; COMMAND=/usr/bin/systemctl start user@1000
Jul 15 23:10:02 qt-apps sudo[209]: pam_unix(sudo:session): session opened for user root(uid=0) by root(uid=1000)
Jul 15 23:10:02 qt-apps systemd[1]: Created slice User Slice of UID 1000.
Jul 15 23:10:02 qt-apps (systemd)[228]: pam_warn(systemd-user:setcred): function=[pam_sm_setcred] flags=0x8002 service=[systemd-user] terminal=[] user=[user1] ruser=[<unknown>] rhost=[<unknown>]
Jul 15 23:10:02 qt-apps systemd[1]: Starting User Runtime Directory /run/user/1000...
Jul 15 23:10:02 qt-apps (systemd)[228]: pam_unix(systemd-user:session): session opened for user user1(uid=1000) by user1(uid=0)
Jul 15 23:10:02 qt-apps systemd[1]: Finished User Runtime Directory /run/user/1000.
Jul 15 23:10:02 qt-apps systemd[1]: Starting User Manager for UID 1000...
Jul 15 23:10:02 qt-apps systemd-logind[192]: New session c1 of user user1.
Jul 15 23:10:02 qt-apps systemd[228]: Queued start job for default target Main User Target.
Jul 15 23:10:02 qt-apps systemd[228]: Created slice User Application Slice.
Jul 15 23:10:02 qt-apps systemd[228]: Reached target Paths.
Jul 15 23:10:02 qt-apps systemd[228]: Reached target Timers.
Jul 15 23:10:02 qt-apps systemd[228]: Starting D-Bus User Message Bus Socket...
Jul 15 23:10:02 qt-apps systemd[228]: Listening on GnuPG network certificate management daemon.
Jul 15 23:10:02 qt-apps systemd[228]: Listening on GnuPG cryptographic agent and passphrase cache (access for web browsers).
Jul 15 23:10:02 qt-apps systemd[228]: Listening on GnuPG cryptographic agent and passphrase cache (restricted).
Jul 15 23:10:02 qt-apps systemd[228]: Listening on GnuPG cryptographic agent (ssh-agent emulation).
Jul 15 23:10:02 qt-apps systemd[228]: Listening on GnuPG cryptographic agent and passphrase cache.
Jul 15 23:10:02 qt-apps systemd[228]: Listening on GnuPG public key management service.
Jul 15 23:10:02 qt-apps systemd[228]: Listening on p11-kit server.
Jul 15 23:10:02 qt-apps systemd[228]: Listening on D-Bus User Message Bus Socket.
Jul 15 23:10:02 qt-apps systemd[228]: Reached target Sockets.
Jul 15 23:10:02 qt-apps systemd[228]: Reached target Basic System.
Jul 15 23:10:02 qt-apps systemd[228]: Reached target Main User Target.
Jul 15 23:10:02 qt-apps systemd[228]: Startup finished in 17ms.
Jul 15 23:10:02 qt-apps systemd[1]: Started User Manager for UID 1000.
Jul 15 23:10:02 qt-apps sudo[209]: pam_unix(sudo:session): session closed for user root
Jul 15 23:10:02 qt-apps sudo[206]: pam_unix(sudo:session): session closed for user user1

Since your XDG_RUNTIME_DIR is managed by systemd, it will not exist when user not logined, and will be destroied when user logout.
https://wiki.archlinux.org/title/XDG_Base_Directory

So I suggest you following this post:

Thank you @catfish. I gave up trying to make this work.

I went back and tried to understand Pam…I have had some success on getting things working, but needs more work.

I posted what I have so far here: /run/user/uid missing when using `incus exec container -- sudo --user uname --login` - #6 by Baba_Open

The container images are based on the respective actual Linux distribution image. That is, the container image that you get in Incus, is as close as possible to the (Desktop) image of the Linux distribution.

Those desktop images are configured so that when you log in interactively, they will set up the environment in the way you want here. You would need either to investigate this setup process so that you can fully replicate but in a non-interactive way, or find someone else on the Internets that has done already this work and use their guide.

If you were to search on the Internet, you would search on how to get an interactive desktop login in Linux in a programmatic/non-interactive way. This assumes that whoever has done already the work, they used the proper high-level description in the title of their guide.

Thank you @simos. I think I am on that path as well…