How to execute command as a specific user

“lxc exec container – sudo --login --user ubuntu” gives me a shell of ubuntu user. How to execute a command from host shell to container as a specific user?

“lxc exec container – ls” execute as root

I need a flag like “–as”

“lxc exec container --as ubuntu – ls”

I found an answer from irc. There is “–user” flag for exec.

lxc exec container --user 1000 – ls

2 Likes