You are here

Linux Container, LXD Spickliste

Seitenübersicht


Container kopieren

Noch zu testen:

shell> lxc remote add
shell> lxc copy CONTAINER_NAME/SNAPSHOT_NAME target:CONTAINER_NAME"

Container clonen

shell> lxc copy ubuntu-container qa-mariadb106-r

Container als tarball exportieren und importieren

shell>  lxc stop qa-glb
shell>  lxc publish qa-glb --alias my-export
Container published with fingerprint: 9f8410af601eb238224919943d146bc1bcd86429c2dcd5332b7d1bcf271d598d
shell>  lxc image export my-export .
Image exported successfully!
shell>  lxc start qa-glb
shell>  ls -ltr *.tar.gz
-rw-rw-r--  1 oli oli  193735169 Oct 17 09:54  9f8410af601eb238224919943d146bc1bcd86429c2dcd5332b7d1bcf271d598d.tar.gz
shell>  scp 9f8410af601eb238224919943d146bc1bcd86429c2dcd5332b7d1bcf271d598d.tar.gz root@othermachine:

shell> lxc image import 9f8410af601eb238224919943d146bc1bcd86429c2dcd5332b7d1bcf271d598d.tar.gz --alias my-export
Image imported with fingerprint: 9f8410af601eb238224919943d146bc1bcd86429c2dcd5332b7d1bcf271d598d
shell> lxc init my-export qa-glb
Creating qa-glb
shell> lxc start qa-glb
shell> lxc 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'
shell> lxc config set ${CONTAINER_NAME} boot.autostart false

shell> lxc 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: ""

shell> lxc config get ${CONTAINER_NAME} boot.autostart
false

Neuen Container von Image Server ziehen und starten

List image servers:

shell> lxc remote list
+-----------------+------------------------------------------+---------------+-----------+--------+--------+
|      NAME       |                   URL                    |   PROTOCOL    | AUTH TYPE | PUBLIC | STATIC |
+-----------------+------------------------------------------+---------------+-----------+--------+--------+
| images          | https://images.linuxcontainers.org       | simplestreams |           | YES    | NO     |
+-----------------+------------------------------------------+---------------+-----------+--------+--------+
| local (default) | unix://                                  | lxd           | 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:

shell> lxc 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:

shell> lxc profile list
+---------+---------+
|  NAME   | USED BY |
+---------+---------+
| default | 4       |
+---------+---------+

Launch a new Container from chosen Image:

shell> lxc launch images:debian/12 debian12-template --profile=default
Creating debian12-template
Starting debian12-template

Container umbenennen

shell> lxc stop qa-debian10-m106
shell> lxc move qa-debian10-m106 qa-debian10-m106-t
shell> lxc start qa-debian10-m106-t                
shell> lxc info qa-debian10-m106-t
Name: qa-debian10-m106-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

shell> lxc file push myfile.txt mycontainer/home/ubuntu/

Quellen