Kontejnery

Instalace LXC

Na Ubuntu je instalace LXC jednoduchá. V první řadě doporučujeme udělat update systému ve VM pro případ, že od vytvoření image došlo k vydání nějakých bezpečnostních updatů. Budeme pracovat jako root, takže pro zjednodušení, abychom nemuseli před všechny příkazy psát sudo, si ulehčíme situaci přepnutím do root shellu pomocí sudo su - .

Update provedeme pomocí dvojice příkazů apt update a apt dist-upgrade. V mém případě byl systém již aktualizován, takže výstup vypadá takto:

root@osboxes:/home/osboxes# apt update
Hit:1 http://de.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://de.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 http://de.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:4 http://de.archive.ubuntu.com/ubuntu focal-security InRelease
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.

root@osboxes:/home/osboxes# apt dist-upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Instalaci LXC pak provedeme pomocí příkazu apt install lxc . Příklad výstupu:

root@osboxes:/home/osboxes# apt install lxc
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  bridge-utils dns-root-data dnsmasq-base libidn11 liblxc-common liblxc1 libpam-cgfs lxc-utils
  lxcfs uidmap
Suggested packages:
  ifupdown btrfs-tools lxc-templates lxctl
The following NEW packages will be installed:
  bridge-utils dns-root-data dnsmasq-base libidn11 liblxc-common liblxc1 libpam-cgfs lxc lxc-utils
  lxcfs uidmap
0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,641 kB of archives.
After this operation, 5,647 kB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://de.archive.ubuntu.com/ubuntu focal/universe amd64 lxcfs amd64 4.0.3-0ubuntu1 [65.3 kB]
Get:2 http://de.archive.ubuntu.com/ubuntu focal/main amd64 bridge-utils amd64 1.6-2ubuntu1 [30.5 kB]
Get:3 http://de.archive.ubuntu.com/ubuntu focal/main amd64 dns-root-data all 2019052802 [5,300 B]
Get:4 http://de.archive.ubuntu.com/ubuntu focal/main amd64 libidn11 amd64 1.33-2.2ubuntu2 [46.2 kB]
Get:5 http://de.archive.ubuntu.com/ubuntu focal/main amd64 dnsmasq-base amd64 2.80-1.1ubuntu1 [314 kB]
Get:6 http://de.archive.ubuntu.com/ubuntu focal/universe amd64 liblxc1 amd64 1:4.0.2-0ubuntu1 [292 kB]
Get:7 http://de.archive.ubuntu.com/ubuntu focal/universe amd64 liblxc-common amd64 1:4.0.2-0ubuntu1 [461 kB]
Get:8 http://de.archive.ubuntu.com/ubuntu focal/universe amd64 libpam-cgfs amd64 1:4.0.2-0ubuntu1 [35.5 kB]
Get:9 http://de.archive.ubuntu.com/ubuntu focal/universe amd64 lxc-utils amd64 1:4.0.2-0ubuntu1 [362 kB]
Get:10 http://de.archive.ubuntu.com/ubuntu focal/universe amd64 lxc all 1:4.0.2-0ubuntu1 [2,968 B]
Get:11 http://de.archive.ubuntu.com/ubuntu focal-updates/universe amd64 uidmap amd64 1:4.8.1-1ubuntu5.20.04 [26.3 kB]
Fetched 1,641 kB in 1s (2,522 kB/s)
Selecting previously unselected package lxcfs.
(Reading database ... 107569 files and directories currently installed.)
Preparing to unpack .../00-lxcfs_4.0.3-0ubuntu1_amd64.deb ...
Unpacking lxcfs (4.0.3-0ubuntu1) ...
Selecting previously unselected package bridge-utils.
Preparing to unpack .../01-bridge-utils_1.6-2ubuntu1_amd64.deb ...
Unpacking bridge-utils (1.6-2ubuntu1) ...
Selecting previously unselected package dns-root-data.
Preparing to unpack .../02-dns-root-data_2019052802_all.deb ...
Unpacking dns-root-data (2019052802) ...
Selecting previously unselected package libidn11:amd64.
Preparing to unpack .../03-libidn11_1.33-2.2ubuntu2_amd64.deb ...
Unpacking libidn11:amd64 (1.33-2.2ubuntu2) ...
Selecting previously unselected package dnsmasq-base.
Preparing to unpack .../04-dnsmasq-base_2.80-1.1ubuntu1_amd64.deb ...
Unpacking dnsmasq-base (2.80-1.1ubuntu1) ...
Selecting previously unselected package liblxc1.
Preparing to unpack .../05-liblxc1_1%3a4.0.2-0ubuntu1_amd64.deb ...
Unpacking liblxc1 (1:4.0.2-0ubuntu1) ...
Selecting previously unselected package liblxc-common.
Preparing to unpack .../06-liblxc-common_1%3a4.0.2-0ubuntu1_amd64.deb ...
Unpacking liblxc-common (1:4.0.2-0ubuntu1) ...
Selecting previously unselected package libpam-cgfs.
Preparing to unpack .../07-libpam-cgfs_1%3a4.0.2-0ubuntu1_amd64.deb ...
Unpacking libpam-cgfs (1:4.0.2-0ubuntu1) ...
Selecting previously unselected package lxc-utils.
Preparing to unpack .../08-lxc-utils_1%3a4.0.2-0ubuntu1_amd64.deb ...
Unpacking lxc-utils (1:4.0.2-0ubuntu1) ...
Selecting previously unselected package lxc.
Preparing to unpack .../09-lxc_1%3a4.0.2-0ubuntu1_all.deb ...
Unpacking lxc (1:4.0.2-0ubuntu1) ...
Selecting previously unselected package uidmap.
Preparing to unpack .../10-uidmap_1%3a4.8.1-1ubuntu5.20.04_amd64.deb ...
Unpacking uidmap (1:4.8.1-1ubuntu5.20.04) ...
Setting up libpam-cgfs (1:4.0.2-0ubuntu1) ...
Setting up lxcfs (4.0.3-0ubuntu1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/lxcfs.service → /lib/systemd/system/lxcfs
.service.
Setting up uidmap (1:4.8.1-1ubuntu5.20.04) ...
Setting up dns-root-data (2019052802) ...
Setting up libidn11:amd64 (1.33-2.2ubuntu2) ...
Setting up bridge-utils (1.6-2ubuntu1) ...
Setting up dnsmasq-base (2.80-1.1ubuntu1) ...
Setting up liblxc1 (1:4.0.2-0ubuntu1) ...
Setting up lxc-utils (1:4.0.2-0ubuntu1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/lxc-net.service → /lib/systemd/system/lxc
-net.service.
Created symlink /etc/systemd/system/multi-user.target.wants/lxc.service → /lib/systemd/system/lxc.ser
vice.
Setting up lxc dnsmasq configuration.
Setting up lxc (1:4.0.2-0ubuntu1) ...
Setting up liblxc-common (1:4.0.2-0ubuntu1) ...
Processing triggers for systemd (245.4-4ubuntu3.3) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for dbus (1.12.16-2ubuntu2.1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.1) ...