Answer the question
In order to leave comments, you need to log in
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
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."
lxc-create1 work1 template1
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 questionAsk a Question
731 491 924 answers to any question