I get a message _sudo: no tty present and no askpass program specified_ when executing a command with sudo inside a container. In the online demo this works OK.
lxc exec container bash
su - ubuntu
sudo apt update
sudo: no tty present and no askpass program specified
Also I added a new user (team) and when trying swapping users with su I get another message
root@lxdone:~# su - ubuntu
ubuntu@lxdone:~$ su - team
su: must be run from a terminal
Note that neither _su_ nor _sudo_ fail when using them as root
Yeah, this is a classical problem that LXD itself can not really do something about. In short, sudo and su should be fixed to handle pty devices from different namespaces. Without going into detail and repeating it all: it's basically another variant of https://github.com/lxc/lxd/issues/936 and https://github.com/lxc/lxd/issues/1724 .
Ok thanks, I thought I had done something wrong generating the image
Hello again, if you enter sudo with argument -S, say, sudo -S apt update it gets the job done
Also this works for su
Most helpful comment
Hello again, if you enter sudo with argument -S, say,
sudo -S apt updateit gets the job done