A lot of people have been asking us how to run LXD on Centos/RHEL 7 in the past.
Up until now, our answer has usually been to use some of the Fedora packages for liblxc, combined with a hand built version of LXD that you then have to manually integrate with your system. So certainly doable but not exactly clean or easy.
But now there is finally a cleaner, much more supportable way for you to get LXD on those systems as there is now a build of snapd that works with Centos/RHEL, letting you use the official LXD snap on those systems.
Note that the state of snapd on Centos/RHEL is still considered early days, so some features may be missing or broken. We did add automatic testing on our side as we do for all the other distributions and so far everything looks good.
Setting things up
The instructions below are based on a clean Centos 7.4 installation.
Rather than applying the new kernel params to only the current kernel, it’s safer to add them to the GRUB_CMDLINE_LINUX variable in /etc/default/grub and then generate the new grub conf with grub2-mkconfig >/boot/grub2/grub.cfg so they apply to all kernels.
Hey all,
anyone having troubles with adding this repo on step two?
I don’t see a way to install snapd in centos7.
Does anyone have a way get this working in Centos 7 with a modern kernel?
yum copr enable ngompa/snapcore-el7
sudo yum copr enable ngompa/snapcore-el7
Loaded plugins: copr, fastestmirror, ovl
You are about to enable a Copr repository. Please note that this
repository is not part of the main Fedora distribution, and quality
may vary.
The Fedora Project does not exercise any power over the contents of
this repository beyond the rules outlined in the Copr FAQ at
<https://fedorahosted.org/copr/wiki/UserDocs#WhatIcanbuildinCopr>, and
packages are not held to any quality or securty level.
Please do not file bug reports about these packages in Fedora
Bugzilla. In case of problems, contact the owner of this repository.
Do you want to continue? [y/N]: y
Error: [Errno 14] HTTPS Error 404 - Not Found
Thanks , this seems to be going forward. I will let you know if something breaks.
Perhaps not the person to ask, but just out of curiosity , utilizing the snapd method, will I be able to continue updating my kernel and having LXD work with it?
EDIT:
It looks like it’s still struggling with name spaces.
[oneadmin@node-1 ~]$ lxc config show
cannot create user data directory: /var/lib/one/snap/lxd/7650: Permission denied
[alex@node-1 one]$ lxc config show
If this is your first time running LXD on this machine, you should also run: lxd init
To start your first container, try: lxc launch ubuntu:16.04
Error: Get http://unix.socket/1.0: dial unix /var/snap/lxd/common/lxd/unix.socket: connect: permission denied
[alex@node-1 one]$ lxd init
Error: Failed to connect to local LXD: Get http://unix.socket/1.0: dial unix /var/snap/lxd/common/lxd/unix.socket: connect: permission denied
The instructions never say sudo echo, they say to run those commands as root.
Running sudo echo abc > def will have echo run as root, but the writing to def part running as your normal user through the shell, which is why you’re getting permission denied.
Run sudo -i and then run the full command as root and it’ll work fine.
Thanks, I ran sudo -i and the echo worked this time.
But after rebooting, I’m getting another error:
[root@localhost ~]# snap install lxd
snap “lxd” is already installed, see “snap refresh --help”
[root@localhost ~]# lxd init
-bash: lxd: command not found