Installation of Calculate LXC Container

LXC

Installing the required packages

To continue, you need to install app-emulation/lxc:

emerge lxc

Installing Calculate into a container

To install Calculate Linux Container, run:

lxc-create -n ccs -t download -- --server mirror.calculate-linux.org --no-validate --arch x86_64
lxc-create -n ccs -t download -- --server mirror.calculate-linux.org --no-validate --arch x86_64
Downloading the image index
WARNING: Running without gpg validation!

---
DIST    RELEASE ARCH    VARIANT BUILD
---
CCDX    17.12.2 x86_64  default 20180308
CCS     17.12.2 x86_64  default 20180308
---

Distribution: 
CCS
Release: 
17.12.2

Downloading the image index
Downloading the rootfs
Downloading the metadata
The image cache is now ready
Unpacking the rootfs

---
You just created a Gentoo container (release=17.12.2, arch=amd64, variant=default)

To enable sshd, run: rc-update add sshd

For security reason, container images ship without user accounts
and without a root password.

Use lxc-attach or chroot directly into the rootfs to set a root password
or create user accounts.

You can replace ccs with the flavour you need. The startup script will list the available ISO images and prompt for a distribution (CCS, capitalized) and a release (17.12.2, the current one when we were writing this manual). The application will automatically fetch the container on the cloud and install it. The installed containers are stored in the /var/calculate/lxc/ directory.

Network configuration

Network configuration of the host computer

To configure the network in a LXC container, you will need to configure the network bridge on the host. If the server has only one dedicated IP address, IP forwarding can be done via a unique interface. If the server has several IPs, network configuration may be done by using the shared network.

Network configuration of the container

Configure the network for your container:

/var/calculate/lxc/ccs/config

# network type if bridge is used
lxc.net.0.type = veth
# start the network at system start
lxc.net.0.flags = up
# interface inside the container
lxc.net.0.name = eth0
# bridge to be used by the virtual interface
lxc.net.0.link = br0
# random MAC for the network interface of the container (first number must be even)
lxc.net.0.hwaddr = 02:03:04:05:06:07

In the path name, replace ccs with the name of your container. Replace the MAC (02:03:04:05:06:07). Note that the first number must be even.

Start the container

To start the container, run:

lxc-start -n ccs

Replace ccs with your container name if necessary.

Make sure the container is up and running:

lxc-info -n ccs
Name:           ccs
State:          RUNNING
PID:            25107
CPU use:        3.03 seconds
BlkIO use:      51.98 MiB
Memory use:     61.21 MiB
KMem use:       4.39 MiB
Link:           vethXLWII2
 TX bytes:      516 bytes
 RX bytes:      516 bytes
 Total bytes:   1.01 KiB

Add the container to autostart:

ln -sf /etc/init.d/lxc /etc/init.d/lxc.ccs

rc-update add lxc.ccs

To make the system in the container start after the network is up, create the lxc file:

/etc/conf.d/lxc

rc_want="net.br0"

Configuring system in the container

Configure the network in the container:

lxc-attach -n ccs -- cl-setup-network --iface eth0:192.168.11.2:24 --route default:192.168.11.1 --dns 8.8.8.8

lxc-attach -n ccs rc-update add net.eth0

In this example, the container uses IP 192.168.11.2 routed via 192.168.11.1. This is correct if you configured the network on the host via address forwarding. If a shared network is used (with local IPs), you can either use DHCP for configuring your network or specify a spare IP address and a router IP.

Set up the locale and specify the root password:

lxc-attach -n cсs -- cl-setup-locale -l en_GB --timezone Europe/London

lxc-attach -n ccs passwd

You can also specify the complete hostname:

lxc-attach -n ccs -- cl-setup-network --hostname ccs.mydomain.org

To check the new hostname, run:

lxc-attach -n ccs -- hostname -f

Adding applications in a container

Update Portage in the container:

lxc-attach -n ccs -- cl-update

At first startup, cl-update will fetch the Portage tree as well as all added overlays.

Now install the software you need for logging and cron jobs:

lxc-attach -n ccs emerge syslog-ng logrotate vixie-cron