6

I am trying to create an lxc container on centos but I am running into the following error: [user@sdn3-lnx-01 ~]$ lxc-create -t centos -n container1

lxc_container: utils.c: get_template_path: 1128 No such file or directory - bad template: centos

lxc_container: lxccontainer.c: lxcapi_create: 1223 bad template: centos

lxc_container: lxc_create.c: main: 274 Error creating container container1

[user@sdn3-lnx-01 ~]$

Could you please help me?

IP Archer
  • 135
  • 2
  • 9
  • I don't know how to mark multiple answers as accurate. I was missing lxc-templates, so i installed them. Then I was supposed to use absolute path with -t option. Thank you @fat_cheng and @ Diego Mora Cespedes. – IP Archer Mar 26 '16 at 00:28

3 Answers3

16

I am not familiar with centos,but on ubuntu,I met the same problem.and I fix it with execute:

sudo apt-get install lxc lxctl lxc-templates

maybe you need install some more packages.

fat_cheng
  • 478
  • 1
  • 5
  • 14
  • To get LXC, LXC documentation, extra LXC tools and the default LXC templates just install the following packages. The templates are stored as shell scripts at /usr/share/lxc/templates . dnf install lxc lxc-doc lxc-extra lxc-templates – Simon Schürg Apr 05 '16 at 02:12
  • Worked for me, Ubuntu 23.04. – code2be Mar 21 '23 at 17:30
5

you can try

lxc-create -n ct1 -t download

& it will provide you with an inter-active solution to create the container & the list of templates & distributions supported

  • After sifting through a lot of pages on internet, this solution worked for me, finally. My host OS - RedHat 7.7 and I was trying to download LXC - CentOS 7 amb64. Worked. – Raman Kathpalia Dec 21 '19 at 17:41
4

Try:

lxc-create -n container-name -t /etc/lxc/templates/lxc-centos --lxcpath=/var/lib/lxc/

You can also try:

lxc-create -n container-name -t /usr/share/lxc/templates/lxc-centos --lxcpath=/var/lib/lxc/

Basically, check which folder contains your template, /etc/lxc/templates/ or /usr/share/lxc/templates/

Diego Mora Cespedes
  • 3,605
  • 5
  • 26
  • 33