How to Create Linux Containers in Ubuntu


Here’s how to do it:

This is the command:

lxc-create -t download -n [New LXC Name] -- --dist [Distribution Name] --release [Release Name] --arch [Architecture]

Explanation:

New LXC Name is the name that you wish to call your new Linux container. I usually name my LXCs using Reverse Domain Name Notation of the domain I wish to use for that LXC, with dashes instead of periods. That means if I wish to host budhajeewa.com in that LXC, I’d name that com-budhajeewa. It allows me to organize my LXCs well.

Distribution Name is the name of the OS that you wish to use for your LXC. There are a number of Linux OSs available, but I always use ubuntu as it’s my favorite OS ?.

Release Name is the version of the OS you want to use. This can be something like xenial, trusty, or precise for Ubuntu.

Architecture allows you to select 64bit or 32 bit edition of the OS. I always use amd64 for this.

So, to create a LXC named “my-lxc” using 64bit Ubuntu 16.04 Xenial, I’d issue the following command:

lxc-create -t download -n my-lxc -- --dist ubuntu --release xenial --arch amd64

Leave a Reply

Your email address will not be published. Required fields are marked *