Cannot run command using lxc-attach, despite being a (working) unprivileged container


When running these commands, with the intention of running commands without entering into a shell, I get the following errors.

# lxc-attach -n vpnLxc -- ls
lxc-attach: vpnLxc: tools/lxc_attach.c: main: 302 You lack access to /home/user/.local/share/lxc

# sudo lxc-attach -n vpnLxc -- ls
lxc-attach: vpnLxc: attach.c: get_attach_context: 405 Connection refused - Failed to get init pid
lxc-attach: vpnLxc: attach.c: lxc_attach: 1469 Connection refused - Failed to get attach context

I’m at a loss why this may be the case, any ideas?


I have the following unprivileged container, which is working fine (I can log in, it’s running the web services I need, etc).

# lxc config show --expanded vpnLxc
architecture: x86_64
  image.architecture: amd64
  image.description: ubuntu 20.04 LTS amd64 (release) (20210927)
  image.label: release
  image.os: ubuntu
  image.release: focal
  image.serial: "20210927"
  image.type: squashfs
  image.version: "20.04"
  volatile.base_image: 56296ba81a6fb502c634697a840d7957c3d2aa1a1805820e605ed21475058851
  volatile.eth0.host_name: vethc6de36da
  volatile.eth0.hwaddr: 00:16:3e:f5:23:7a
  volatile.idmap.base: "0"
  volatile.idmap.current: '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":100000,"Nsid":0,"Maprange":65536}]' '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":100000,"Nsid":0,"Maprange":65536}]'
  volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":100000,"Nsid":0,"Maprange":65536}]'
  volatile.last_state.power: RUNNING
  volatile.uuid: d7bc7358-b05f-46dc-95a1-51a28c30f553
    name: eth0
    nictype: bridged
    parent: br0
    type: nic
    path: /
    pool: lxcDefaultPool
    type: disk
    path: /home/ubuntu/media
    source: /home/share_user/media
    type: disk
ephemeral: false
- default
stateful: false
description: ""