我无法将命令放入我的 lxc 容器或根本无法进入我的容器(显示错误:未找到)

我无法将命令放入我的 lxc 容器或根本无法进入我的容器(显示错误:未找到)

新手尝试在 16.04 上使用 lxc 容器。它正在运行,但我无法在其中发出命令或进入它(尝试过“uptime”,但任何命令都一样)。而且它似乎没有我“认为”(什么都不知道!)它应该有的 IP 地址。任何帮助都非常感谢...

$
$ lxc-info --name myBusyBox
Name:           myBusyBox
State:          RUNNING
PID:            19826
Memory use:     248.00 KiB
KMem use:       0 bytes
Link:           veth4OF01M
 TX bytes:      0 bytes
 RX bytes:      0 bytes
 Total bytes:   0 bytes
$ 
$
$ lxc exec myBusyBox -- uptime
error: not found
$
$ lxc exec myBusyBox -- sudo --login --user fred
error: not found
$ lxc exec myBusyBox -- sudo --login --user root
error: not found
$ 
$
$ lxc exec --debug myBusyBox -- uptime
DBUG[04-29|19:03:33] Connecting to a local LXD over a Unix socket 
DBUG[04-29|19:03:33] Sending request to LXD                   etag= method=GET url=http://unix.socket/1.0
DBUG[04-29|19:03:33] Got response struct from LXD 
DBUG[04-29|19:03:33] 
    {
        "config": {},
        "api_extensions": [
            "id_map",
            "id_map_base",
            "resource_limits"
        ],
        "api_status": "stable",
        "api_version": "1.0",
        "auth": "trusted",
        "auth_methods": null,
        "public": false,
        "environment": {
            "addresses": [],
            "architectures": [
                "x86_64",
                "i686"
            ],
            "certificate": "-----BEGIN CERTIFICATE-----\nMIIFgzCCbla..bla..blaEYn5/TQjrObuGJCQ=\n-----END CERTIFICATE-----\n",
            "certificate_fingerprint": "08a74b..bla..bla..7d75a",
            "driver": "lxc",
            "driver_version": "2.0.8",
            "kernel": "Linux",
            "kernel_architecture": "x86_64",
            "kernel_version": "4.4.0-121-generic",
            "server": "lxd",
            "server_pid": 13686,
            "server_version": "2.0.11",
            "storage": "dir",
            "storage_version": ""
        }
    } 
DBUG[04-29|19:03:33] Connected to the websocket 
DBUG[04-29|19:03:33] Sending request to LXD
                   etag= method=POST url=http://unix.socket/1.0/containers/myBusyBox/exec
DBUG[04-29|19:03:33] 
    {
        "command": [
            "uptime"
            ],
        "wait-for-websocket": true,
        "interactive": true,
        "environment": {
            "HOME": "/root",
            "TERM": "xterm",
            "USER": "root"
        },
        "width": 248,
        "height": 76,
        "record-output": false
    } 
error: not found
$
$ cat .config/lxc/default.conf 
lxc.id_map = u 0 362144 65536
lxc.id_map = g 0 362144 65536
lxc.network.type = veth
lxc.network.link = lxcbr0
$ 
$ ifconfig
eth0      Link encap:Ethernet  HWaddr dc:4a:3e:3d:38:fa  
          inet addr:192.168.69.28  Bcast:192.168.69.255  Mask:255.255.255.0
          inet6 addr: fe80::b776:cc17:bfde:7c50/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1947862 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1602785 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:904087759 (904.0 MB)  TX bytes:224598229 (224.5 MB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:24177 errors:0 dropped:0 overruns:0 frame:0
          TX packets:24177 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:2465959 (2.4 MB)  TX bytes:2465959 (2.4 MB)

lxcbr0    Link encap:Ethernet  HWaddr 00:16:3e:00:00:00  
          inet addr:10.0.3.1  Bcast:0.0.0.0  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lxdbr0    Link encap:Ethernet  HWaddr 6a:dc:61:40:be:3c  
          inet addr:10.114.49.1  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::68dc:61ff:fe40:be3c/64 Scope:Link
          inet6 addr: fdbc:db09:9173:641c::1/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1359 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:314674 (314.6 KB)

veth4OF01M Link encap:Ethernet  HWaddr fe:7f:6e:24:b3:db  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

$ 
$ lxc list
+------+-------+------+------+------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------+-------+------+------+------+-----------+
$ 
$

答案1

LXC和之间存在重要区别LXD

LXC是创建和管理容器的原始、较旧(但仍受支持)方式。 的命令行工具LXC是类似lxc-create和 的命令lxc-info。也就是说,它们只是以 开头的命令lxc-

LXD是创建和管理容器的新方法,它比 更简单、更用户友好LXC。使用LXD,您可以使用lxc命令执行所有管理任务。例如,lxc launch ubuntu:18.04 mycontainer将使用 Ubuntu 18.04 创建一个名为 mycontainer 的新容器。lxc info mycontainer将显示有关容器的信息。此外,LXD已预安装在 Ubuntu 上。LXC不是。

很多人在LXD使用该lxc命令时感到困惑。

您可以在以下网址详细了解差异https://discuss.linuxcontainers.org/t/comparing-lxd-vs-lxc/24

回到你的问题。你使用了用 创建的容器的LXD命令。lxcLXC

相关内容