My LXC 3.0.2 installation is missing ubuntu template

I’m running Ubuntu on VirtualBox (4.15.0-36-generic #39 Ubuntu SMP Mon Sept 24 UTC 2018 x86_64 GNU/Linux). I’m following an Ansible tutorial which uses LXC for containers. I’ve installed LXC 3.0.2 and proceeded to create LXC containers as instructed: lxc-create -t ubuntu -n webX, but received an error:

lxc-create: webX: utils.c: get_template_path: 872 No such file or directory - bad template: ubuntu
lxc-create: webX: lxccontainer.c do_lxcapi_create: 1784 Unknown template “ubuntu”

I’ve searched and discovered that indeed the ubuntu template is not present in the templates directory in my install path (/usr/share/lxc/templates) only have the following templates listed: lxc-busybox, lxc-download, lxc-local and lxc-oci, there is not ubuntu.

The tutorial requires the ubuntu template which my lxc distro does not have. What can I do to fix that?

I could create containers using ‘busybox’ template but when I start it and attach to it, it doesn’t have apt, or apt-get, or ssh… so it’s not sufficient for what i need to do.

lxc-create is part of the LXC 1.0 suite. For 3.x you should be using lxc init (Not lxd init). To achieve what your command shows, you should try:

lxc init ubuntu webX

Note that if you do not specify anything for ubuntu, you will be getting what the current image repository considers the “preferred” release.

I tried that command, but I got "Error: Get http://unix.socket/1.0: dial unix /var/lib/lxd/unix.socket: connect: connection refused.

I was logged on as root…

How could uninstall lxc 3.x and install lxc 1.0 or 2.0 so that I could follow the tutorial commands without missing a beat… i have no need for lxc 3.x - it’s just the default configuation that got installed when I ran: apt-get --update && apt-get install lxc

Have you initialized your LXD instance? This is done by running lxd init and answering some questions.

It is neither recommended, not supported to run LXC 1.0 in what I assume is Ubuntu 18.04. Also, if I am not mistaken, the commands you try to use are deprecated also in LXD 2.x

It worked - thank you VERY much!

1 Like

I got my three instances running WITH the IP addresses attached and available. How can I attach to these instances?

You can use lxc exec container_name bash to attach to your new containers

Ah - so just like docker containers, then - thx very much for this weekend crash course.

1 Like

There is LXC and there is LXD. The first is an older project and has commands that look like lxc-create. LXD is newer and more user-friendly. If you do not know which to use, use LXD. LXD has commands like lxc launch.

Unfortunately, many confuse the two and use the commands interchangeably. This is messy.

maybe lxd should come with a text file or man page that explains what is going on, a tiny shell script to display it, and a bunch of symlinks for lxc-* commands that refer to that script. i guess the target base of users for the explanation are those who have been using lxc 1.0.

LXC 1.0 predates LXD and many old users started with LXC 1.0.

For new users, I recommend to use LXD. There are many features and functionality that make it easy to learn.

i want to become an “old user” … the ones that understand intimately what is going on under the hood.

1 Like