You are not logged in.

#1 2013-07-26 18:11:21

unibrow
Member
Registered: 2013-07-22
Posts: 1

Using LXC to create an ubuntu container

Hey all,

I've used LXC to create an ubuntu 12.04 container while using ubuntu as the host, but just trying a quick at doing the same on my arch box:

lxc-create -t ubuntu -n chef 

This fails because the ubuntu template is using the 'arch' command, which doesn't even exist anymore in arch linux.  I made that command by using uname -m, , but then got hit by another missing command, debootstrap, which I got from AUR and then hit another error as it tried to build the container.

Anyway, I'm feeling like I'm headed into unchartered/unsupported territory--is there anyone who has done this, and can vouch for it being something that's possible?

Thanks!

Offline

#2 2013-08-07 20:29:44

teekay
Member
Registered: 2011-10-26
Posts: 271

Re: Using LXC to create an ubuntu container

It's possible, sure. Even the archlinux template is broken and pretty outdated in regards to systemd. You just need to fix the template, don't give up after the 3rd error, you already fixed the first two! :-)
(I dind't try ubuntu, but archlinux and centos - took a while to get them running)

Offline

#3 2013-08-15 16:34:18

evilhamsterman
Member
Registered: 2013-08-15
Posts: 11

Re: Using LXC to create an ubuntu container

I am attempting it too, it appears that chrooting into the container is not referencing the /etc/environment file so the PATH is not setup. Obviously without PATH it can't find any of the tools. I'm not sure why it isn't sourcing /etc/environment.

Offline

#4 2013-08-15 19:37:26

evilhamsterman
Member
Registered: 2013-08-15
Posts: 11

Re: Using LXC to create an ubuntu container

I was able to install an Ubuntu image using the ubuntu-cloud template rather than the regular template. This will download a precreated image like is used in Amazon EC2 rather than build one using debootstrap. This means you don't even need debootstrap installed. You do have to comment out line 276 in /usr/share/lxc/templates/lxc-ubuntu-cloud

#type ubuntu-cloudimg-query

That checks to see if the ubuntu-cloudimg-query tool is installed. The tools is used to find the url for the requested Ubuntu image but you can just manually specify it instead. I was able to create a template then with the following command and start it

lxc-create -n ubuntu -t ubuntu-cloud -- -r raring -T http://cloud-images.ubuntu.com/raring/current/raring-server-cloudimg-amd64-root.tar.gz
lxc-start -n ubuntu

It will include some cloud-utils and cloud-init packages that aren't necessary on LXC so you can remove them or leave them if you want.

It will also require you to redownload the image everytime, for some reason it won't just used the cached image. I would get around that by creating a base image with the above line, customize it the way you want, then clone it when you need a new image

lxc-clone -o ubuntu-template -n ubuntu-new

Hope this helps

Offline

#5 2013-08-15 19:38:06

evilhamsterman
Member
Registered: 2013-08-15
Posts: 11

Re: Using LXC to create an ubuntu container

Also if you are using btrfs lxc-clone is really fast because it just snapshots the original

Offline

#6 2013-12-04 14:43:17

starfry
Member
From: Surrey, UK
Registered: 2010-08-18
Posts: 230

Re: Using LXC to create an ubuntu container

Following the evilhamsterman, I created a container. However, it was created without networking because that's how the template created its configuration:

# grep lxc.network /var/lib/lxc/gitserver-ubuntu/config
lxc.network.type = empty

I changed this to

lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0 
lxc.network.name = eth0
lxc.network.mtu = 1500

and, with that change made, the container started fine and had a working network connection.

Did I miss something else that I should have done which would have avoided this? Hopefully not and, if so, I hope this little extra piece of information is of use to somebody else.
(I think this post is the most approriate place for this information. I do hope the powers that be don't condier this a necro-bump - apologies if you do neutral )

Offline

#7 2014-02-03 08:49:34

solar
Member
Registered: 2011-03-01
Posts: 77

Re: Using LXC to create an ubuntu container

@starfry... well , there are a few things to consider.. ;lxc are *not* production ready.... using network with a root container = pwned.

It is better to play around with them with no network till user mapping and whatnot is in place.


I am hilariously insane. yup. you won't notice though.. I promise...I think.

Offline

#8 2014-02-03 09:46:48

starfry
Member
From: Surrey, UK
Registered: 2010-08-18
Posts: 230

Re: Using LXC to create an ubuntu container

@solar I think LXC is production ready if you know what you are doing. I have been using it for four years now (OpenVZ before that). If you correctly configure the container it's pretty secure and safe but, admittedly, I only use them on closed internal systems. Recent versions are much better and the systemd integration finally works making them a pretty good solution IMO. Like all things, it's up to the admin (i.e. me) to make sure things are secure.

Offline

#9 2014-02-03 16:06:47

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: Using LXC to create an ubuntu container

I don't know if this is what you are looking for at all, but have you checked out docker?  It makes container use mindbogglingly simple to use.  It even has a container management system that allows you to search and download existing working containers to use.  I like LXC alone, but I just started playing with docker the other day, and it kind of blew my mind.  It was not what I was expecting at all... it was better.


Edit: splling smile

Last edited by WonderWoofy (2014-02-03 16:07:13)

Offline

#10 2014-03-05 12:07:51

Zipfer
Member
Registered: 2012-05-24
Posts: 9

Re: Using LXC to create an ubuntu container

sudo bash -c "touch /usr/bin/arch && echo 'uname -m' > /usr/bin/arch && chmod +x /usr/bin/arch"
this is workaround for non existing arch command

and where can I post about this issue for arch community

Offline

Board footer

Powered by FluxBB