如何将 bash 或 shell 连接到 lxd 容器

How to connect a bash or shell to a lxd container

我的系统上有很多 lxd 容器。我无法从网络访问它们我没有密码

有没有办法附加一个 bash 就像我们可以在 docker 上做的那样?

在远程 LXD 上启用网络:

lxc config set core.https_address [::]:8443
lxc config set core.trust_password PASSWORD 

将目标主机添加为远程主机(它会要求PASSWORD):

lxc remote add REMOTE_NAME IP_ADDRESS

运行 远程系统上的命令:

lxc exec REMOTE_NAME:CONTAINER COMMAND

在大多数情况下,要获得 shell,您可以将 bashsh 作为命令传递。

更多信息在这里: https://web.archive.org/web/20160818010904/https://www.stgraber.org/2016/04/12/lxd-2-0-remote-hosts-and-container-migration-612/