The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Neriyan (5) [Avatar] Offline
#1
I created and started a new lxc container. However when installing snapd I got the following:


root@myContainer:/home/ubuntu# apt install snapd
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
zenity | kdialog
The following NEW packages will be installed:
snapd
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 12.4 MB of archives.
After this operation, 57.8 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 snapd amd64 2.34.2+18.04 [12.4 MB]
Fetched 12.4 MB in 7s (1,781 kB/s)
Selecting previously unselected package snapd.
(Reading database ... 14084 files and directories currently installed.)
Preparing to unpack .../snapd_2.34.2+18.04_amd64.deb ...
Unpacking snapd (2.34.2+18.04) ...
Setting up snapd (2.34.2+18.04) ...
snapd.snap-repair.service is a disabled or a static unit, not starting it.
Job for snapd.service failed because the control process exited with error code.
See "systemctl status snapd.service" and "journalctl -xe" for details.
Job for snapd.seeded.service failed because the control process exited with error code.
See "systemctl status snapd.seeded.service" and "journalctl -xe" for details.
Cache read/write disabled: interface file missing. (Kernel needs AppArmor 2.4 compatibility patch.)
Warning: unable to find a suitable fs in /proc/mounts, is it mounted?

Use --subdomainfs to override.
root@myContainer:/home/ubuntu#


Thereafter I checked the stystemctl status and got the following:

root@myContainer:/home/ubuntu# systemctl status snapd.service
? snapd.service - Snappy daemon
Loaded: loaded (/lib/systemd/system/snapd.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2018-12-10 04:13:52 UTC; 2min 8s ago
Process: 1525 ExecStart=/usr/lib/snapd/snapd (code=exited, status=1/FAILURE)
Main PID: 1525 (code=exited, status=1/FAILURE)

Dec 10 04:13:52 myContainer systemd[1]: snapd.service: Service hold-off time over, scheduling restart.
Dec 10 04:13:52 myContainer systemd[1]: snapd.service: Scheduled restart job, restart counter is at 5.
Dec 10 04:13:52 myContainer systemd[1]: Stopped Snappy daemon.
Dec 10 04:13:52 myContainer systemd[1]: snapd.service: Start request repeated too quickly.
Dec 10 04:13:52 myContainer systemd[1]: snapd.service: Failed with result 'exit-code'.
Dec 10 04:13:52 myContainer systemd[1]: Failed to start Snappy daemon.

Various forums online suggest trying different things related to changing the kernel. I am a Linux novice so I am unsure if I should be doing this. Any help would be greatly appreciated.
David Clinton (92) [Avatar] Offline
#2
Which version of Linux (Ubuntu?) are you using? And are you using LXC or LXD? If you can successfully run
lxc list
then you know you've got LXD installed.
Neriyan (5) [Avatar] Offline
#3
I am using Ubuntu 18.04.

On the host (i.e. not the container):

root@neriyan-Dell-System-XPS-L702X:/var/lib/lxc/myContainer/rootfs# lxc list

Command 'lxc' not found, but can be installed with:

snap install lxd # version 3.7, or
apt install lxd-client

See 'snap info lxd' for additional versions.


I thought this was strange since I have managed to create and start the lxc container as per the book. I then tried to install lxc as per the book:

root@neriyan-Dell-System-XPS-L702X:/var/lib/lxc/myContainer/rootfs# apt install lxc
Reading package lists... Done
Building dependency tree
Reading state information... Done
lxc is already the newest version (3.0.2-0ubuntu1~18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.


I also tried installing lxd-client as per the error message and got the following:

root@neriyan-Dell-System-XPS-L702X:/var/lib/lxc/myContainer/rootfs# apt install lxd-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
lxd
The following NEW packages will be installed:
lxd-client
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 3,004 kB of archives.
After this operation, 10.9 MB of additional disk space will be used.
Get:1 http://za.archive.ubuntu.com/ubuntu bionic-updates/main amd64 lxd-client amd64 3.0.2-0ubuntu1~18.04.1 [3,004 kB]
Fetched 3,004 kB in 3s (1,153 kB/s)
Selecting previously unselected package lxd-client.
(Reading database ... 172460 files and directories currently installed.)
Preparing to unpack .../lxd-client_3.0.2-0ubuntu1~18.04.1_amd64.deb ...
Unpacking lxd-client (3.0.2-0ubuntu1~18.04.1) ...
Setting up lxd-client (3.0.2-0ubuntu1~18.04.1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ..
.

lxc list then gives me the following:

root@neriyan-Dell-System-XPS-L702X:/var/lib/lxc/myContainer/rootfs# lxc list
Error: Get http://unix.socket/1.0: dial unix /var/lib/lxd/unix.socket: connect: no such file or directory



Still no luck.

David Clinton (92) [Avatar] Offline
#4
You might have LXC - the older version, as opposed to LXD - installed. That would definitely explain why
lxc list

didn't work. It might also explain why you're unable to properly install LXD. To confirm this, try running
lxc-ls -fancy

That's the equivalent of lxc list for LXC. If LXC is installed. If the command is successful, than you've got LXC.
To be honest, I was worried that we might fall into this kind of confusion: having two versions of the tool available at the same time both using similar "lxc" based commands is just asking for trouble.
Let me know what you see.
Neriyan (5) [Avatar] Offline
#5
Thank you for your assistance. It seems that I have lxc installed:

root@neriyan-Dell-System-XPS-L702X:/home/neriyan# lxc-ls -f
NAME        STATE   AUTOSTART GROUPS IPV4                 IPV6 UNPRIVILEGED 
myContainer RUNNING 0         -      10.0.3.239, 10.0.4.1 -    false        



David Clinton (92) [Avatar] Offline
#6
Ok. So assuming that it's the LXC install that's getting in the way of LXD, you have two choices. You could continue using LXC (using the basic commands from the book), or you could completely remove LXC using
apt purge lxc

and install LXD. The snap should then work, or you could simply use:
apt install lxd

Be aware though, that your myContainer container will probably be crippled if you remove LXC. If that's not a problem (for instance, you've got no important work or data on the container) then I would suggest you move up to LXD - simply because it is the new standard and, going forward, it's going to be the default.
Does that sound reasonable?
David Clinton (92) [Avatar] Offline
#7
I'm going to wait to hear how things work out for you and then I think I'll add a warning for other readers to the book's errata page - this could be a problem for others, too.
Neriyan (5) [Avatar] Offline
#8
Thank you for all your assistance David. I have successfully removed lxc, installed lxd and got the snap to install. Everything is seems to be in order.
David Clinton (92) [Avatar] Offline
#9
Excellent. Thanks for the update.