0

A newbie attempting lxc container on 16.04. It's running but I cant issue command in it or get into it at all (tried 'uptime' here but any command is the same). Also it doesn't seem to have an IP address which I 'think'(knowing nothing!) it should have. Any help much appreciated...

$
$ 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 |
+------+-------+------+------+------+-----------+
$ 
$
0

There is an important difference between LXC and LXD.

LXC is the original, older (but still supported) way to create and manage containers. The command line tools for LXC are commands like lxc-create and lxc-info. That is, they are only commands that start with lxc-.

LXD is the new way to create and manage containers, and it is much easier and user-friendly than LXC. With LXD, you use the lxc command for all management tasks. For example, lxc launch ubuntu:18.04 mycontainer will create a new container called mycontainer with Ubuntu 18.04. lxc info mycontainer will show info about the container. Also, LXD is pre-installed on Ubuntu. LXC is not.

There are quite a few people that get confused when LXD uses the lxc command.

You can read more about the differences at https://discuss.linuxcontainers.org/t/comparing-lxd-vs-lxc/24

To come back to your question. You used the LXD command lxc for a container that was created with LXC.

  • Thx for help Simos, lxc <> lxd - how confusing ! For the record, this is what finally worked.. uninstall everything and then these commands $ sudo apt-get update $ sudo apt install lxd lxd-client $ sudo lxd init $ reboot $ lxc list +------+-------+------+------+------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +------+-------+------+------+------+-----------+ $ lxc launch ubuntu:16.04 first Creating first Starting first $ lxc exec first -- /bin/bash root@first:~# root@first:~# whoami root – RichEarle May 15 '18 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.