Installation de Calculate en LXC

Updated 22 Mars 2022


Installer les paquets requis

Pour continuer, vous devez installer app-emulation/lxc:

emerge -a app-emulation/lxc

Installation de Calculate dans un conteneur

Pour installer Calculer Linux Container, exécutez:

lxc-create -n calculate -t download -- --server --arch x86_64
Downloading the image index
WARNING: Running without gpg validation!

CCG     22.0.1  x86_64  default 20220317
CCS     22.0.1  x86_64  default 20220317


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=18, 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.

Replace calculate with any name you want for your container. Сценарий загрузки отобразит доступные образы и попросит указать дистрибутив и релиз. Последовательно введите CCS заглавными буквами и релиз 22.0.1. L'application récupère automatiquement le conteneur sur le cloud et l'installe. Les conteneurs installés sont stockés dans le répertoire /var/calculate/lxc/


In subsequent commands and paths, use the container name you replaced calculate with.

Configuration du réseau

Configuration réseau de l'ordinateur hôte

Pour configurer le réseau dans un conteneur LXC, vous devez configurer le pont réseau sur l'hôte. To do this, select one of the two configuration options:

  • If the host computer has multiple IP addresses - for example, if you will run the container on a desktop operating in the local network and receiving the IP via DHCP - you can configure the network by [using shared network containers] (network#ispolzovanie_obshchei_seti).
  • If the host computer has a single IP address - for example, when running a container on a VPS or dedicated server - you can configure [network address translation] (network#transliatsiia_ip-adresov) via a single interface.

Configuration du réseau du conteneur

Configurez le réseau pour votre conteneur:


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

Replace the MAC address, 02:03:04:05:06:07. Please note that the first number must be even (addresses with an odd first number are multicast and cannot be assigned).

Démarrer le conteneur

Pour démarrer le conteneur, exécutez:

lxc-start calculate

Assurez-vous que le conteneur est prêt à fonctionner:

lxc-info calculate
Name:           calculate
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

Ajouter le conteneur au démarrage automatique:

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

rc-update add lxc.calculate

In order for the system in the container to start correctly once the network is up, create a file containing the following rule:



Configuration du système dans le conteneur

Connect to the container to make further modifications or adjustments.

lxc-attach calculate


You can also edit settings in the container from the host computer, using the following syntax:



Network configuration when using a shared network

If you are using a shared network (with local IPs), you can configure the network either with DHCP or by specifying an available IP address and a router IP address.

When using a DHCP server on a local network, you simply have to run the following:

/etc/init.d/net.eth0 start

rc-update add net.eth0

Network configuration when using NAT

If using [network address translation (NAT)] (network#transliatsiia_ip-adresov), edit the host settings accordingly:

cl-setup-network --iface eth0: --route default: --dns

rc-update add net.eth0

In the example, the container uses IP ~ to route via ~

Other settings

Check the localization parameters and set the root password:

cl-setup-locale -l ru_RU --timezone Europe/Moscow


Vous pouvez également spécifier le nom d'hôte complet:

cl-setup-network --hostname

To check the changes, run:

hostname -f

Ajout d'applications dans un conteneur

Mettre à jour Portage dans le conteneur:


The first time you run the tool, it pulls the Portage tree and enabled overlays.

Installez maintenant le logiciel dont vous avez besoin pour la journalisation et les travaux cron:

emerge -a app-admin/logrotate app-admin/syslog-ng sys-process/cronie

When you have completed the configuration, exit the container:


Update to v.4.0

Starting with LXC 4.0, one configuration file common.conf is used instead of separate files for the different container types. When upgrading app-emulation/lxc from previous versions, adjustments must be made to the settings of the already prepared containers. Edit the path to the common configuration file:


#lxc.include = /usr/share/lxc/config/gentoo.common.conf
lxc.include = /usr/share/lxc/config/common.conf

To run programs that use /dev/shm (e.g. PostgreSQL), add the tmpfs mount to this path in the configuration file of the container:


lxc.mount.entry = none dev/shm tmpfs rw,nosuid,nodev,create=dir


Containers are useful as they remain separated from the main system. You can experiment with them and even launch Calculate Linux from other systems.