Lxd: Fail to use sudo inside a container

Created on 24 Apr 2017  路  5Comments  路  Source: lxc/lxd

lxc info

  • Distribution: Ubuntu
  • Distribution version: 16.04
  • The output of "lxc info" or if that fails:
    config:
    core.https_address: 0.0.0.0:8443
    core.trust_password: true
    apiextensions:

    • id_map

      apistatus: stable

      apiversion: "1.0"

      auth: trusted

      public: false

      environment:

      addresses:

    • 10.8.9.130:8443

      architectures:

    • x86_64

    • i686

      driver: lxc

      driverversion: 2.0.3

      kernel: Linux

      kernelarchitecture: x86_64

      kernelversion: 4.4.0-31-generic

      server: lxd

      serverpid: 9342

      serverversion: 2.0.9

      storage: dir

      storageversion: ""

Issue description

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.

Steps to reproduce

lxc exec container bash
su - ubuntu
sudo apt update
sudo: no tty present and no askpass program specified

Most helpful comment

Hello again, if you enter sudo with argument -S, say, sudo -S apt update it gets the job done

All 5 comments

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

Was this page helpful?
0 / 5 - 0 ratings