Linux Container, Incus Spickliste
Mo., 2022-10-17 10:10 —
oli
Seitenübersicht
- Container kopieren
- Container clonen
- Container als tarball exportieren und importieren
- Autostart eines Containers deaktivieren
- Launch new Container from Image server
- Container umbenennen
- File von Host in Container kopieren/pushen
- Wo liegen die Container rum?
- Quellen
Container kopieren
Noch zu testen:
$ incus remote add
$ incus copy CONTAINER_NAME/SNAPSHOT_NAME target:CONTAINER_NAME"
Container clonen
$ incus copy ubuntu-container qa-mariadb118-r
Container als tarball exportieren und importieren
$ incus stop qa-glb
$ incus publish qa-glb --alias my-export
Container published with fingerprint: 9f8410af601eb238224919943d146bc1bcd86429c2dcd5332b7d1bcf271d598d
$ incus image export my-export .
Image exported successfully!
$ incus start qa-glb
$ ls -ltr *.tar.gz
-rw-rw-r-- 1 oli oli 193735169 Oct 17 09:54 9f8410af601eb238224919943d146bc1bcd86429c2dcd5332b7d1bcf271d598d.tar.gz
$ scp 9f8410af601eb238224919943d146bc1bcd86429c2dcd5332b7d1bcf271d598d.tar.gz root@othermachine:
$ incus image import 9f8410af601eb238224919943d146bc1bcd86429c2dcd5332b7d1bcf271d598d.tar.gz --alias my-export
Image imported with fingerprint: 9f8410af601eb238224919943d146bc1bcd86429c2dcd5332b7d1bcf271d598d
$ incus init my-export qa-glb
Creating qa-glb
$ incus start qa-glb
$ incus list
+----------------+---------+----------------------+-----------------------------------------------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+----------------+---------+----------------------+-----------------------------------------------+-----------+-----------+
| qa-glb | RUNNING | 10.153.125.95 (eth0) | | CONTAINER | 0 |
+----------------+---------+----------------------+-----------------------------------------------+-----------+-----------+
Autostart eines Containers deaktivieren
Wichtig: Wenn nichts gesetzt ist, bleibt die Ausgabe leer!
CONTAINER_NAME="qa-glb"
$ incus config set ${CONTAINER_NAME} boot.autostart false
$ incus config show ${CONTAINER_NAME}
architecture: x86_64
config:
boot.autostart: "false"
image.architecture: amd64
image.description: Ubuntu jammy amd64 (20221013_07:42)
image.os: Ubuntu
image.release: jammy
image.serial: "20221013_07:42"
volatile.base_image: c68a9e1ce45aeaa74957a00f35eb4da8947ee8b00be11ad199128ff00d5e1586
volatile.eth0.hwaddr: 00:16:3e:3f:29:48
volatile.idmap.base: "0"
volatile.idmap.next: "[{"Isuid":true,"Isgid":false,"Hostid":296608,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":296608,"Nsid":0,"Maprange":65536}]"
volatile.last_state.idmap: "[{"Isuid":true,"Isgid":false,"Hostid":296608,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":296608,"Nsid":0,"Maprange":65536}]"
volatile.last_state.power: RUNNING
devices: {}
ephemeral: false
profiles:
- default
stateful: false
description: ""
$ incus config get ${CONTAINER_NAME} boot.autostart
false
Neuen Container von Image Server ziehen und starten
List image servers:
$ incus remote list
+-----------------+------------------------------------------+---------------+-----------+--------+--------+
| NAME | URL | PROTOCOL | AUTH TYPE | PUBLIC | STATIC |
+-----------------+------------------------------------------+---------------+-----------+--------+--------+
| images | https://images.linuxcontainers.org | simplestreams | | YES | NO |
+-----------------+------------------------------------------+---------------+-----------+--------+--------+
| local (default) | unix:// | incus | tls | NO | YES |
+-----------------+------------------------------------------+---------------+-----------+--------+--------+
| ubuntu | https://cloud-images.ubuntu.com/releases | simplestreams | | YES | YES |
+-----------------+------------------------------------------+---------------+-----------+--------+--------+
| ubuntu-daily | https://cloud-images.ubuntu.com/daily | simplestreams | | YES | YES |
+-----------------+------------------------------------------+---------------+-----------+--------+--------+
List images from an image server with filters:
$ incus image list images: debian amd64
+---------------------------+--------------+--------+----------------------------------------+--------+----------+-------------------------------+
| ALIAS | FINGERPRINT | PUBLIC | DESCRIPTION | ARCH | SIZE | UPLOAD DATE |
+---------------------------+--------------+--------+----------------------------------------+--------+----------+-------------------------------+
| debian/10 (7 more) | acc938c533e4 | yes | Debian buster amd64 (20221118_05:24) | x86_64 | 75.39MB | Nov 18, 2022 at 12:00am (UTC) |
+---------------------------+--------------+--------+----------------------------------------+--------+----------+-------------------------------+
| debian/10/cloud (3 more) | b3620508e8f0 | yes | Debian buster amd64 (20221118_05:25) | x86_64 | 91.67MB | Nov 18, 2022 at 12:00am (UTC) |
+---------------------------+--------------+--------+----------------------------------------+--------+----------+-------------------------------+
| debian/11 (7 more) | 05ed772255b4 | yes | Debian bullseye amd64 (20221118_05:25) | x86_64 | 83.53MB | Nov 18, 2022 at 12:00am (UTC) |
+---------------------------+--------------+--------+----------------------------------------+--------+----------+-------------------------------+
| debian/11/cloud (3 more) | d504a27d47e9 | yes | Debian bullseye amd64 (20221118_05:26) | x86_64 | 101.91MB | Nov 18, 2022 at 12:00am (UTC) |
+---------------------------+--------------+--------+----------------------------------------+--------+----------+-------------------------------+
| debian/12 (7 more) | 75a85d176731 | yes | Debian bookworm amd64 (20221118_06:09) | x86_64 | 93.95MB | Nov 18, 2022 at 12:00am (UTC) |
+---------------------------+--------------+--------+----------------------------------------+--------+----------+-------------------------------+
| debian/12/cloud (3 more) | 1c93807b372f | yes | Debian bookworm amd64 (20221118_05:24) | x86_64 | 118.75MB | Nov 18, 2022 at 12:00am (UTC) |
+---------------------------+--------------+--------+----------------------------------------+--------+----------+-------------------------------+
| debian/sid (3 more) | 638d5e88fa16 | yes | Debian sid amd64 (20221118_05:26) | x86_64 | 94.91MB | Nov 18, 2022 at 12:00am (UTC) |
+---------------------------+--------------+--------+----------------------------------------+--------+----------+-------------------------------+
| debian/sid/cloud (1 more) | 21ad1ca920a3 | yes | Debian sid amd64 (20221118_05:25) | x86_64 | 119.69MB | Nov 18, 2022 at 12:00am (UTC) |
+---------------------------+--------------+--------+----------------------------------------+--------+----------+-------------------------------+
List available profiles:
$ incus profile list
+---------+---------+
| NAME | USED BY |
+---------+---------+
| default | 4 |
+---------+---------+
Launch a new Container from chosen Image:
$ incus launch images:debian/12 debian12-template --profile=default
Creating debian12-template
Starting debian12-template
Container umbenennen
$ incus stop qa-debian10-m118
$ incus move qa-debian10-m118 qa-debian10-m118-t
$ incus start qa-debian10-m118-t
$ incus info qa-debian10-m118-t
Name: qa-debian10-m118-t
Remote: unix://
Architecture: x86_64
Created: 2022/11/21 16:38 UTC
Status: Running
Type: persistent
Profiles: default
...
File von Host in Container kopieren/pushen
$ incus file push myfile.txt mycontainer/home/ubuntu/
Wo liegen die Container rum?
# pwd
/var/lib/incus/storage-pools/default/containers
# ls -lad *template
d--x------+ 4 root root 4.0K Nov 21 2022 debian10-template
d--x------+ 4 root root 4.0K Nov 21 2022 debian11-template
d--x------ 4 root root 4.0K Oct 5 2023 debian12-template
d--x------+ 4 root root 4.0K Nov 21 2022 rocky8-template
d--x------+ 4 root root 4.0K Nov 18 2022 rocky9-template
d--x------+ 4 root root 4.0K Nov 21 2022 ubuntu2004-template
d--x------+ 4 root root 4.0K Nov 18 2022 ubuntu2204-template
d--x------ 4 root root 4.0K Feb 26 08:34 ubuntu2404-template

