W
W
wibuhu2013-11-27 18:13:05
Virtualization
wibuhu, 2013-11-27 18:13:05

How to create a template for LXC containers in Ubuntu?

Hi all.
There was a task for which you need your own template (based on Ubuntu but with your own pre-installed set of software and files) for containers under lxc. Unfortunately, on the Internet, I have not found a clear article on this topic.
Thanks in advance for your replies.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya Evseev, 2013-11-28
@IlyaEvseev

Create a new container:
Customize everything in it to your liking.
Turn off: lxc-stop -n template1
An example script for creating a new container from a template:

#!/bin/sh
# /usr/local/sbin/lxc-create1 -- written for http://toster.ru/q/53902

Die() { echo "Error: $*"; exit 1; }

test $# = 2 || Die "wrong args, must be: $0 newname template"
echo "Try to create $1 from $2..."

DSTDIR="/var/lib/lxc/$(basename $1)"; test -d "$DSTDIR" && Die "$DSTDIR already exist"
SRCDIR="/var/lib/lxc/$(basename $2)"; test -d "$SRCDIR" || Die "$SRCDIR not exist"

mkdir "$DSTDIR" || Die "cannot create $DSTDIR"
tar cf - -C "$SRCDIR" . | tar xf - -C "$DSTDIR"

cd "$DSTDIR" || Die "cannot jump to $DSTDIR"
sed -i "s,$2,$1," config fstab

echo "Done."

Create a container from a template:
lxc-create1 work1 template1

S
Sergey Nalomenko, 2014-12-13
@benjaminsmith

Of course available. For example, like this:

ul {
    -moz-column-count: 4;
    -moz-column-gap: 20px;
    -webkit-column-count: 4;
    -webkit-column-gap: 20px;
    column-count: 4;
    column-gap: 20px;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question