0

I'm using Ubuntu 16.04 and lxc 2.0.7-0ubuntu1~16.04.1, I got this error sudo: no tty present and no askpass program specified in an unprivileged container( Ubuntu 16.04 amd64).

This is my /dev

ubuntu@unpc:~$ ls -al /dev/
total 4
drwxr-xr-x  6 root   root       500 Feb 22 08:57 ./
drwxr-xr-x 21 root   root      4096 Feb 22 04:15 ../
crw--w----  1 root   tty     136, 6 Feb 22 09:02 console
lrwxrwxrwx  1 root   root        11 Feb 22 08:57 core -> /proc/kcore
lrwxrwxrwx  1 root   root        13 Feb 22 08:57 fd -> /proc/self/fd/
crw-rw-rw-  1 nobody nogroup   1, 7 Feb 21 07:00 full
drwxr-xr-x  2 root   root        40 Feb 22 08:57 hugepages/
lrwxrwxrwx  1 root   root        25 Feb 22 08:57 initctl -> /run/systemd/initctl/fifo|
lrwxrwxrwx  1 root   root        28 Feb 22 08:57 log -> /run/systemd/journal/dev-log=
drwxrwxrwt  2 nobody nogroup     40 Feb 22 08:57 mqueue/
crw-rw-rw-  1 nobody nogroup   1, 3 Feb 21 07:00 null
lrwxrwxrwx  1 root   root        13 Feb 22 08:57 ptmx -> /dev/pts/ptmx
drwxr-xr-x  2 root   root         0 Feb 22 08:57 pts/
crw-rw-rw-  1 nobody nogroup   1, 8 Feb 21 07:00 random
drwxrwxrwt  2 root   root        40 Feb 22 08:57 shm/
lrwxrwxrwx  1 root   root        15 Feb 22 08:57 stderr -> /proc/self/fd/2
lrwxrwxrwx  1 root   root        15 Feb 22 08:57 stdin -> /proc/self/fd/0
lrwxrwxrwx  1 root   root        15 Feb 22 08:57 stdout -> /proc/self/fd/1
crw-rw-rw-  1 nobody nogroup   5, 0 Feb 22 09:06 tty
crw--w----  1 root   tty     136, 0 Feb 22 09:02 tty1
crw--w----  1 root   tty     136, 1 Feb 22 09:02 tty2
crw--w----  1 root   tty     136, 2 Feb 22 09:02 tty3
crw--w----  1 root   tty     136, 3 Feb 22 09:02 tty4
crw-rw-rw-  1 nobody nogroup   1, 9 Feb 21 07:00 urandom
crw-rw-rw-  1 nobody nogroup   1, 5 Feb 21 07:00 zero
2
  • How did you log in to the container? Did you use SSH, or lxc exec?
    – ph0t0nix
    Apr 26, 2017 at 8:55
  • I forget the details, I think it's lxc exec and got this error, so I have to modify sudoers, let the user use sudo without password.
    – dawncold
    Apr 26, 2017 at 9:18

1 Answer 1

0

I had a similar problem.

This is what solved for me.

Add this to your config:

# /dev/console
lxc.cgroup.devices.allow                = c 5:1 rwm
# /dev/ptmx
lxc.cgroup.devices.allow                = c 5:2 rwm
# /dev/pts/*
lxc.cgroup.devices.allow                = c 136:* rwm
# /dev/tty
lxc.cgroup.devices.allow                = c 5:0 rwm

Reference: https://lists.linuxcontainers.org/pipermail/lxc-users/2012-January/003150.html

1
  • Thanks rsd, but I got an error: lxc_cgfsng - cgroups/cgfsng.c:cgfsng_setup_limits:1949 - No such file or directory - Error setting devices.allow to c 5:1 rwm for unpc, I confirmed there is a char device with marjor number 5 and minor number 1
    – dawncold
    Jun 14, 2017 at 1:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .