Debian – Unable to install packages in LXC unprivileged container

containersdebiandebian-jessielxc

I am new to the whole containers thing.
I have successfully create an unprivileged wheezy container on a debian 8.8 host using lxc 2.0.7. But when I'm trying to:

lxc-attach -n container1 -- apt-get install openssh-server

I got this error message:

Preconfiguring packages ...
dpkg: warning: 'ldconfig' not found in PATH or not executable
dpkg: warning: 'start-stop-daemon' not found in PATH or not executable
dpkg: error: 2 expected programs not found in PATH or not executable
Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin
E: Sub-process /usr/bin/dpkg returned an error code (2)

The PATH contains only the followings

/usr/local/bin:/usr/bin:/bin:/usr/games

I also tried to spin up some other containers with ubuntu xenial but the result were the same.

what am I missing?

Thanks in advice.

Best Answer

Using the option --clear-env in lxc-attach did the trick.